Binning for a histogram.

4 ビュー (過去 30 日間)
Chad
Chad 2011 年 12 月 2 日
I am unable to find an effecive method to bin the following data.
11.8652 3.5891
12.5513 6.6741
11.8652 3.5891
8.8125 1.1711
8.8125 2.3422
8.8125 1.1711
5.7598 0.3324
5.0737 0.9444
5.7598 0.3324
12.5513 6.6741
14.1000 19.0596
12.5513 6.6741
8.8125 2.3422
0.0000 0.0000
8.8125 2.3422
5.0737 0.9444
3.5250 7.2712
5.0737 0.9444
11.8652 3.5891
12.5513 6.6741
11.8652 3.5891
8.8125 1.1711
8.8125 2.3422
8.8125 1.1711
5.7598 0.3324
5.0737 0.9444
5.7598 0.3324
For example I am trying to
Energy = Sum
14.1000 = 19.0596
12.5513 = 6.6741 + 6.6741 + 6.6741 + 6.6741
11.8652 = 3.5891 + 3.5891 + 3.5891 + 3.5891
8.8125 = 1.1711 + 1.1711 + 1.1711 + 1.1711 + 2.3422 + 2.3422 + 2.3422 + 2.3422
so on and so forth
I would like to then plot(Energy,Sum) while not repeating the Energy. I cannot find away to do this. I appreciate the help.
  1 件のコメント
Doug Hull
Doug Hull 2011 年 12 月 2 日
huh? It is not clear what you are doing.

サインインしてコメントする。

採用された回答

Walter Roberson
Walter Roberson 2011 年 12 月 2 日
[uvals, a, uidx] = unique(YourData(:,1));
Sum = accumarray(uidx, YourData(:,2));
plot(uvals, Sum)
  1 件のコメント
Chad
Chad 2011 年 12 月 2 日
Very nice...it works great!

サインインしてコメントする。

その他の回答 (1 件)

Hin Kwan Wong
Hin Kwan Wong 2011 年 12 月 2 日
Make an array with A=[energy sum] Then use:
A=sortrows(A);
hist(A(:,2),A(:,1))

カテゴリ

Help Center および File ExchangeStatistics and Machine Learning Toolbox についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by