4.36364

4.4 | 11 ratings Rate this file 47 Downloads (last 30 days) File Size: 1.4 KB File ID: #14205
image thumbnail

2D Histogram

by Murphy O'Brien

 

09 Mar 2007 (Updated 09 Mar 2007)

Calculates and draws the 3D histogram of 2 Dimensional input data

| Watch this File

File Information
Description

function H = hist2d(D,Xn,Yn,[Xlo Xhi],[Ylo Yhi])

Calculates and draws the 3D histogram of 2 Dimensional input data D.

Counts number of points in the bins defined by
X = linspace(Xlo,Xhi,Xn) and
Y = linspace(Ylo,Yhi,Yn)

 D must be a 2 column or 2 row matrix or an array of complex numbers

 [Xlo Xhi],[Ylo Yhi] are optional and default to the min and max of
 the input data
 Xn and Yn are optional and default to 20

 Example:
  hist2d([randn(1,10000); randn(1,10000)])

Really just a copy of 2D Histogram, by Rey Patlolla, but with default arguments, optionally complex input and draws a 3D histogram.

Acknowledgements

The author wishes to acknowledge the following in the creation of this submission:
2-Dimensional Histogram
This submission has inspired the following:
Fast 2D histogram calculation

MATLAB release MATLAB 7.2 (R2006a)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (12)
24 Jul 2007 General Tricky

Handy tool

28 Sep 2007 Aureli Soria-Frisch  
16 Feb 2008 Adama Ouattara

Good !

07 Mar 2008 Brian Liswell

Easy to implement. Grinds out fairly quickly on my PC.
The responses for the 2D Histogram entry say stuff about bugs - any clue what those are?

Know of any way to make a rectangular topped surface instead of angular surf?

18 Jul 2008 umair qureshi

fairly easy to understand and use !! hats off to u!!

01 Aug 2008 Reda Boufatah

very good demonstration using hist

05 Sep 2008 Kamrul Hakim  
15 Apr 2009 David

Simple and useful!

15 Apr 2009 David

A nice, easy-to-use function; though I've just discovered that the statistics toolbox has a function hist3 with this functionality.

28 Jun 2010 Thomas

This function works, but it is much slower than hist3 on large data sets. For instance, on two arrays of ~500,000 length, this function took ~30 s while hist3 took ~0.1 s.

03 Sep 2010 Juan Dominguez

Great function. Used it before discovering hist3.

31 May 2011 Jochem  
Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
statistics Murphy O'Brien 22 Oct 2008 09:03:07
probability Murphy O'Brien 22 Oct 2008 09:03:07
2d histogram Cristina McIntire 15 Jan 2009 13:40:17
3d histogram Cristina McIntire 15 Jan 2009 13:40:17
statistics Model Ramachandran 27 Aug 2009 05:54:33
3d histogram kumar vishwajeet 15 Jul 2010 02:16:24
3d histogram Michel 09 Aug 2011 18:04:59
2d histogram Janis 25 Aug 2011 09:21:10

Contact us at files@mathworks.com