Histograms in Matlab
histograms and vertical data
The hist instruction
in Matlab, without output arguments, produces a histogram bar plot
of the results.
The bar edges on the first and last bins may
extend to cover the min
and max of
the data unless a matrix of data is supplied.
A histogram is a graphical representation used to estimate the
distribution of a variable. It counts the
frequencies of data into discrete intervals (bins), and then
plots a rectangle over each interval.
Matlab code creates a histogram with 3 bars. The first bar has two '1'
values, the second bar has three '2' values, and the third bar
one '3' values.
y = [1 1 2 2 2 3]
The horizontal axis
has the different values in the vector to be plotted.
The vertical axis
has the number of those values in the vector.
This Matlab code generates a histogram of 15 randomly distributed
numbers between 0 and 1 (you can type 'help rand' on your
command window to learn about random numbers).
a = randn(15,1)
Note that each column includes a range of values, otherwise
the histogram would contain 15 bars.
You can type ' help hist
' or ' help bar
' on your command window to see more details of use.