File Exchange

image thumbnail


version (3.9 KB) by Durga Lal Shrestha
Combined good features of hist and histc

1 Download

Updated 04 Apr 2016

View License

AHIST Alternative to Histogram.
Motivation: to combine the good features of HIST and HISTC.
n = ahist(Y)
n = ahist(Y,nbin)
n = ahist(Y,xedges)
[n,xc,index] = ahist(...)
ahist(...) without output arguments produces a
histogram bar plot of the results.

Y: Vector or Matrix of data. If Y is Matrix, AHIST works down
the columns.
nbin: Number of bins
xedges: Matrix of edges for each column vector of data

n: Number of elements in each container.
xc: The position of the bin centers in X
index: Index matrix BIN.

1. Returns the index matrix (histc)
2. Either uses nbins (hist) or xedges (histc)
3. Returns centre of the bin (hist)
4. Plot histogram of each column of matrix in subplots

1. Note that in histc, the last bin counts any values of x that
match edges(end). But AHIST(Y) bins the elements of Y into 10 equally
spaced containers like in hist.
2. When working the matrix, HIST and HISTC uses same container based on
the range of the whole matrix for all column of the matrix.
But AHIST uses different container for each column based on the range
of data in each column.


Copyright 2004-2007 by Durga Lal Shrestha.
$Date: 2007/10/02
$Revision: 1.0.0 $ $Date: 2007/10/02 $

Cite As

Durga Lal Shrestha (2020). AHIST (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (2)


Dimitri Shvorob

The multi-column functionality is new, but rather special; I think I'll stick with own HISTF for now :)


BSD License

MATLAB Release Compatibility
Created with R2007a
Compatible with any release
Platform Compatibility
Windows macOS Linux