# hist

## Purpose

Histogram plot.

## Synopsis

    hist
    hist(y)
    hist(y,nb)
    hist(y,x)
    [n,x] = hist(y,...)

## Description

`hist` calculates or plots histograms.

`hist(y)` draws a 10-bin histogram for the data in vector `y`. The bins are equally spaced between the minimum and maximum values in `y`.

`hist(y,nb)` draws a histogram with `nb` bins.

`hist(y,x)`, if `x` is a vector, draws a histogram using the bins specified in `x`.

`[n,x] = hist(y)`, `[n,x] = hist(y,nb)`, and `[n,x] = hist(y,x)` do not draw graphs, but return vectors `n` and `x` containing the frequency counts and the bin locations such that `bar(x,n)` plots the histogram. This is useful in situations where more control is needed over the appearance of a graph, for example, to combine a histogram into a more elaborate plot.

## Examples

Generate bell-curve histograms from Gaussian data.

    x = -2.9:0.1:2.9;
    y = randn(10000,1);
    hist(y,x)

## ``See Also

    bar, stairs

(c) Copyright 1994 by The MathWorks, Inc.