logo for matrixlab-examples.com
[?] Subscribe To This Site

XML RSS
Add to Google
Add to My Yahoo!
Add to My MSN
Subscribe with Bloglines


Home
Matrixmania Blog
Contact
-> Sitemap <-
Matlab Books
Quick Matlab Guide
Matlab Tutorials
Matlab Examples
Matlab Flow Control
Boolean Algebra
Linear Algebra
Matlab 2D Plots
Matlab 3D Plots
Matlab GUI
Matlab Cookbook I
Matlab Cookbook II
Probability and Stats
Forums and Help
Relevant Links
Fun!
Your own Website?
Terms/Policies
leftimage for matrixlab-examples.com

hist - Histograms in Matlab




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.

Example:



This 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 has one '3' values.

y = [1 1 2 2 2 3]
hist(y)

histogram 1
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.


Example:




This Matlab code generates a histogram of 15 randomly distributed numbers between 0 and 1.

a = randn(15,1)
hist(a)

a =
   -0.8468
   -0.2463
    0.6630
   -0.8542
   -1.2013
   -0.1199
   -0.0653
    0.4853
   -0.5955
   -0.1497
   -0.4348
   -0.0793
    1.5352
   -0.6065
   -1.3474

>>
hist 2
Note that each column includes a range of values, otherwise the histogram would contain 15 bars.


From 'hist' to home
From 'hist' to 'Matlab Plots'

footer for hist page