help in making a cumulative histogram, histc or accumarray?

1 次查看(过去 30 天)
All,
I have some data that I would like to create a cumulative histogram of. The bins I would like to use are like
bins=[0.2 15 0.4 15 0.6 15 0.8 15 1 15 1.2 15 1.4 15 1.6 15 1.8 15 2 15];
and a section of my data looks like
data = [0.072
0.085
0.118
0.200
0.325
0.527
0.823
1.193
1.553
1.822
1.952
1.907
1.707
1.468
1.287
1.200
1.138
1.038
0.898
0.778
0.667
0.599
0.563
0.511
0.434
0.356
0.300
0.266
0.247
0.216
0.199
0.183
0.165
0.131
0.081
0.058
0.051
0.037
0.022
0.019
0.032
0.034
0.034
0.034
0.033
0.020
0.017
0.016
0.017
0.017
0.003];
Given that the bins are non monotonically decreasing/increasing, accumarray and histc throw up errors, does anyone know how I might make this kind of cumulative histogram?
Thanks,
Jim

采纳的回答

Walter Roberson
Walter Roberson 2012-10-24
ubins = unique(bins);
bar( ubins, cumsum( histc( data, ubins ) ) );

更多回答(1 个)

Image Analyst
Image Analyst 2012-10-24
Why can't you just sort your bins and then pass them into histc. But you didn't specify if your bins were bin centers or bin edges.

类别

Help CenterFile Exchange 中查找有关 Histograms 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by