MATLAB Function Reference

histogram2

Compute a two dimensional histogram

Syntax

Description

The discriptor describes the cells of the histogram. The discriptor consists of two row vectors with three elements [lowerx,upperx,ncellx;lowery,uppery,ncelly]. The default values are lowerx=min(x)-deltax/2, upperx=max(x)+deltax/2 and ncellx=ceil(length(x)^(1/3)), where deltax=(max(x)-min(x))/(length(x)-1) and similar for y.

Its assumed that lowerx < upperx, lowery < uppery, ncelly >= 1, ncelly >= 1 and length(x) == length(y). Futhermore its assumed that both x and y are row vectors.

The result is a matrix vector containing the histogram of x and y. The indices (indexx,indexy) of the histogram cells are computed by indexx = round( (x(i)-lowerx) / (upperx-lowerx) * ncellx ) + 1/2 and indexy = round( (x(i)-lowery) / (uppery-lowery) * ncelly ) + 1/2. If one of the indices is out of the range 1 <= indexx <= ncellx or 1 <= indexy <= ncelly, consequently x(i) < lowerx, upperx <= x(i),y(i) < lowery or uppery <= y(i), the elements x(i) and y(i) are excluded from the histogram.

See Also

histogram

Literature

None

Source code

histogram2.m

MATLAB Function Reference


Copyright R. Moddemeijer