File Exchange

## 2D Histogram

version 1.0 (1.4 KB) by

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

4.46154
14 Ratings

Updated

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.

Mubashir

Weijia Yang

### Weijia Yang (view profile)

Really useful. Thank you!

Liang

Jochem

Juan Dominguez

### Juan Dominguez (view profile)

Great function. Used it before discovering hist3.

Thomas

### Thomas (view profile)

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.

David

### David (view profile)

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

David

### David (view profile)

Simple and useful!

Kamrul Hakim

Reda Boufatah

very good demonstration using hist

umair qureshi

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

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?

Good !

Aureli Soria-Frisch

General Tricky

Handy tool

##### MATLAB Release
MATLAB 7.2 (R2006a)