help in making a cumulative histogram, histc or accumarray?

2 views (last 30 days)
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

Accepted Answer

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

More Answers (1)

Image Analyst
Image Analyst on 24 Oct 2012
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.

Categories

Find more on Data Distribution Plots in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!