3.66667

3.7 | 6 ratings Rate this file 16 Downloads (last 30 days) File Size: 850 Bytes File ID: #8422

2-Dimensional Histogram

by Rey Patlolla

 

04 Sep 2005 (Updated 06 Sep 2005)

Accumulate and plot a 2d histogram matrix.

| Watch this File

File Information
Description

function H = histo2D(D,[Xlo Xhi],Xn,[Ylo Yhi],Yn,Xlab,Ylab,Title)
 
2-Dimensional Histogram
(size(H) == [Yn Xn])
Counts number of points in the bins defined by -
X = linspace(Xlo,Xhi,Xn) and
Y = linspace(Ylo,Yhi,Yn)

Example:
Dx = 5*rand(100,1) ;
Dy = 10*rand(50,1) ;
D = [Dx,Dy] ;
H = histo2D(D,[0 5],10,[0 10],5, 'Xlabel','Ylabel','2d Histogram') ;

Acknowledgements

The author wishes to acknowledge the following in the creation of this submission:
2D Histogram Matrix
This submission has inspired the following:
2D Histogram

MATLAB release MATLAB 7.0.4 (R14SP2)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (7)
13 Jun 2006 Jascha Sohl-Dickstein

This is exactly what I was looking for. Thank you!

14 Jun 2006 Paulo L

An example does not work.

24 Jul 2006 Ty Woo

Exactly what I was looking for. Had to fix the code only a little.

11 Jun 2007 Ian Thorpe

Works very well and is easy to modify for your own needs. I had to transpose X and Y in the dsearchn calls to get it to work.

19 Jan 2008 tudor t

it's very slow, and it becomes a nuisance for large matrices -- it's almost an order of magnitude slower than the other hist2d, the one that uses histc; however, that one has a bug;

also, there's something funny with the plot, it seems it omits 1 row and 1 column...

anyway, it's easier to write than to debug so I wrote my own :-)

24 Nov 2009 Pearl  
06 Aug 2010 Aaron Swan

MATLAB provides the function hist3 to generate bivariate histograms

Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
statistics Rey Patlolla 22 Oct 2008 07:59:22
probability Rey Patlolla 22 Oct 2008 07:59:22
histogram Rey Patlolla 22 Oct 2008 07:59:22
2d histogram Rey Patlolla 22 Oct 2008 07:59:22
2 dimensional histogram Rey Patlolla 22 Oct 2008 07:59:22
histogram AM 08 Aug 2011 14:54:32
2 dimensional histogram Natalie 07 Oct 2011 06:01:43
2d histogram Natalie 07 Oct 2011 06:01:48
histogram Natalie 07 Oct 2011 06:01:51
probability Natalie 07 Oct 2011 06:01:55
statistics Natalie 07 Oct 2011 06:01:57

Contact us at files@mathworks.com