www.gusucode.com > dsp 案例源码程序 matlab代码 > dsp/ComputeHistogramOfASequenceExample.m

    %% Compute Histogram of a Sequence
%%
% *Note*: This example runs only in R2016b or later. If you are using an
% earlier release, replace each call to the function with the equivalent
% |step| syntax. For example, myObject(x) becomes step(myObject,x).
%%
% Compute a histogram with four bins, for possible input values 1 through
% 4.
myhistogram = dsp.Histogram(1,4,4);
y = step(myhistogram, [1 2 2 3 3 3 4 4 4 4]');
%%
% y is equal to [1; 2; 3; 4] - one ones, two twos, etc.