A question about the histograms please
情報
この質問は閉じられています。 編集または回答するには再度開いてください。
古いコメントを表示
Hi everyone, As can be seen in the attached image, my histogram is built using counts, I WROTE THE FOLLOWING CODE TO CONVERT COUNTS TO %, how can i know exactly the percent of each load bin
figure,
>> histogram([tandem{K}]);
ylabels = get(gca, 'YTickLabel');
ylabels = linspace(0,100,length(ylabels));
set(gca,'YTickLabel',ylabels);
0 件のコメント
回答 (1 件)
the cyclist
2017 年 12 月 14 日
編集済み: the cyclist
2017 年 12 月 14 日
As described in the documentation for the histogram function, you can used the 'Normalization' input parameter:
histogram(tandem{K},nbins,'Normalization','probability')
13 件のコメント
MAHMOUD ALZIOUD
2017 年 12 月 14 日
Image Analyst
2017 年 12 月 14 日
Simply multiply by 100! (Did you look at the help documentation?)
histObject = histogram(tandem,nbins,'Normalization','probability')
percentages = 100 * histObject.Values
Steven Lord
2017 年 12 月 14 日
Call histogram and specify the 'probability' Normalization as the cyclist showed, but specify an output argument when you call it. Then get the Values property of the handle returned from histogram. Alternately, if you don't need the graphics object call histcounts with that same Normalization option.
MAHMOUD ALZIOUD
2017 年 12 月 14 日
MAHMOUD ALZIOUD
2017 年 12 月 14 日
編集済み: MAHMOUD ALZIOUD
2017 年 12 月 14 日
Image Analyst
2017 年 12 月 14 日
Try this:
edges = linspace(6000, 82000, 41); % 41 edges for 40 bins.
histObject =histogram(tandem{K}, edges, 'Normalization', 'probability')
MAHMOUD ALZIOUD
2017 年 12 月 14 日
the cyclist
2017 年 12 月 14 日
編集済み: the cyclist
2017 年 12 月 14 日
I'm confused. It sounds like you are trying to specify values that are in the range on the y-axis. You should be specifying the edges of the bins with the values of the x axis. So maybe you just want
linspace(0,40,41)
instead of what you did.
You also don't really need to use linspace for that. The vector
0:40
will give the same.
MAHMOUD ALZIOUD
2017 年 12 月 14 日
the cyclist
2017 年 12 月 14 日
OK, then
linspace(0,82000,41)
should work. But the figure you posted here has x-axis that are in the range 0-60 ("Load in Kips"), so I'm still a bit confused. (Maybe you just relabeled the X tick labels?)
MAHMOUD ALZIOUD
2017 年 12 月 14 日
Image Analyst
2017 年 12 月 14 日
Is your data in the range 0 to 80, or 0 to 80,000? Either way, just use linspace and put in the overall min and overall max, and the number of bins you want to form the edges.
MAHMOUD ALZIOUD
2017 年 12 月 14 日
この質問は閉じられています。
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!