3.66667

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

2-Dimensional Histogram

by Rey Patlolla

 

04 Sep 2005 (Updated 06 Sep 2005)

No BSD License  

Accumulate and plot a 2d histogram matrix.

Download Now | 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 (6)
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  
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
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com