´how to plot bar graph with one set of data

3 Ansichten (letzte 30 Tage)
Yogesh Babu
Yogesh Babu am 1 Jul. 2014
Kommentiert: Star Strider am 4 Jul. 2014
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...

Akzeptierte Antwort

Star Strider
Star Strider am 1 Jul. 2014
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 Kommentare
Yogesh Babu
Yogesh Babu am 4 Jul. 2014
Thanks alot this really works !!
Star Strider
Star Strider am 4 Jul. 2014
My pleasure!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by