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!