How I can plot this bar graph

1 回表示 (過去 30 日間)
Arsal15
Arsal15 2016 年 2 月 28 日
編集済み: Stephen23 2016 年 2 月 29 日
This bar graph shows on y axis the time and on x axis the number of points.
I want to plot this bar graph as such that it gives accumulated value of 0.8 entries and 0.9 entries like histogram do. Mean its thickness remain same but its height increases with accumulation of entries. for 0.8 it shows height 10 and for 0.9 it shows height 6.
Actually in my problem set 0.8 and 0.9 are the time axis and this 10 and 6 represents the number of data packet generated in that time instant. like 0.8 comes first so at 0.8 time instant 10 data packets generated and at 0.9 time instant 6 data packet and so on..
I hope this will help in understanding what I want to do. I just want to work like histogram using bar plot. so I want to automatically plot the data set using bar graph.

回答 (1 件)

Stephen23
Stephen23 2016 年 2 月 29 日
編集済み: Stephen23 2016 年 2 月 29 日
If the values were integer then it would be possible using unique, but because you have floating-point values I would recommend that you use John D'Errico's very neat FEX submission consolidator:
tol = 0.05;
Y = [0.8,0.8,0.8,0.8,0.9,0.8,0.9,0.9,0.9,0.8,0.8,0.9,0.8,0.9,0.8,0.8,0.9];
[~,ycon,ind] = consolidator(Y,[],'count',tol);
bar(1:numel(ind),ycon(ind))
If you have a newer version of MATLAB you could alternatively use uniquetol.

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by