´how to plot bar graph with one set of data

조회 수: 14 (최근 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 CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by