### Function Reference: `histfit`

statistics: histfit (x)
statistics: histfit (x, nbins)
statistics: histfit (x, nbins, distname)
statistics: histfit (ax, …)
statistics: h = histfit (…)

Plot histogram with superimposed distribution fit.

`histfit (x)` plots a histogram of the values in the vector x using the number of bins equal to the square root of the number of non-missing elements in x and superimposes a fitted normal density function.

`histfit (x, nbins)` plots a histogram of the values in the vector x using nbins number of bins in the histogram and superimposes a fitted normal density function.

`histfit (x, nbins, distname)` plots a histogram of the values in the vector x using nbins number of bins in the histogram and superimposes a fitted density function from the distribution specified by distname.

`histfit (ax, …)` uses the axes handle ax to plot the histogram and the fitted density function onto followed by any of the input argument combinations specified in the previous syntaxes.

`h = histfit (…)` returns a vector of handles h, where `h(1)` is the handle to the histogram and `h(1)` is the handle to the density curve.

Note: calling `fitdist` without any input arguments will return a cell array of character vectors listing all supported distributions.

See also: bar, hist, normplot, fitdist

Source Code: histfit

### Example: 1

     histfit (randn (100, 1))

### Example: 2

     histfit (poissrnd (2, 1000, 1), 10, "Poisson")

### Example: 3

     histfit (betarnd (3, 10, 1000, 1), 10, "beta")