Azzera filtri
Azzera filtri

How I can plot this bar graph

1 visualizzazione (ultimi 30 giorni)
Arsal15
Arsal15 il 28 Feb 2016
Modificato: Stephen23 il 29 Feb 2016
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.

Risposte (1)

Stephen23
Stephen23 il 29 Feb 2016
Modificato: Stephen23 il 29 Feb 2016
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.

Community Treasure Hunt

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

Start Hunting!

Translated by