필터 지우기
필터 지우기

help in making a cumulative histogram, histc or accumarray?

조회 수: 4 (최근 30일)
Jim O'Doherty
Jim O'Doherty 2012년 10월 24일
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
Jim O'Doherty
Jim O'Doherty 2012년 10월 25일
excellent, thanks for your help. I was lacking the cumsum part.
Jim

댓글을 달려면 로그인하십시오.

추가 답변 (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