´how to plot bar graph with one set of data

14 visualizaciones (últimos 30 días)
Yogesh Babu
Yogesh Babu el 1 de Jul. de 2014
Comentada: Star Strider el 4 de Jul. de 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...

Respuesta aceptada

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

Iniciar sesión para comentar.

Más respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by