Plotting histogram question ?
2 次查看(过去 30 天)
显示 更早的评论
How do I plot the histogram of a set of data values in terms of percentage of cumulative frequency? Something like, I want the range to be from 0 to 100%, not from 0 to total number of data.
I am not sure if I made myself understood. Please do ask for details if you need any.
0 个评论
采纳的回答
Fangjun Jiang
2011-8-13
a=rand(100,1);
a(a>=0.7)=1;
a(a<=0.2)=2;
a(a<0.7 & a>0.2)=3;
figure(1);n=hist(a(:),0:5);
percent=n/sum(n);
figure(2);bar(0:5,percent);
6 个评论
Walter Roberson
2011-8-13
Warning: the logic used above will fail if there are no values to be histogrammed. sum(n) would be 0 and you would get 0/0 . Be safe, program defensively!
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Histograms 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!