´how to plot bar graph with one set of data

10 ビュー (過去 30 日間)
Yogesh Babu
Yogesh Babu 2014 年 7 月 1 日
コメント済み: Star Strider 2014 年 7 月 4 日
Hello, I have one column of data in that i have to make a plot the number of occurrence of same data in that column.for example w=(1,2,5,78,89,3,4,5,6,1,2,3,4,6,71,2,3,4,4,1,2,3,4,7,8,9,9) from this data i have to plot how many time 1 number is in this data and 2 number occurrence.
Please let me know how to solve it...

採用された回答

Star Strider
Star Strider 2014 年 7 月 1 日
One way:
w=[1,2,5,78,89,3,4,5,6,1,2,3,4,6,71,2,3,4,4,1,2,3,4,7,8,9,9];
ctrs = [min(w):max(w)];
cnt = hist(w,ctrs);
out = [ctrs; cnt];
% fprintf(1,'\n\tNr\tFreq\n')
% fprintf(1,'\t%2d\t%4d\n', out)
figure(1)
bar(ctrs, cnt, 'r')
grid
xlabel('Number')
ylabel('Counts')
  2 件のコメント
Yogesh Babu
Yogesh Babu 2014 年 7 月 4 日
Thanks alot this really works !!
Star Strider
Star Strider 2014 年 7 月 4 日
My pleasure!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by