How to get values over x-axis from a plotted Histogram?
13 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Abhimanyu Gupta
am 25 Apr. 2020
Beantwortet: Srivardhan Gadila
am 1 Mai 2020
I plotted a histogram using the historgram() method, somewhat similar to this-

I wish to note the values over y-axis and x-axis.
I can get the values over y-axis pretty easily using histogram.Values.
For corresponding x-axis values, using the histogram.BinEdges, I get values as: -0.5 0.5 1.5 2.5 3.5 4.5 5.5, but what I want is: 0 1 2 3 4 5.
I tried looking into complete properties of Histogram but coudln't found a property useful to me.
I could do that manually by running the following piece of code.
ranges=Histogram.BinEdges;
x=zeros(Histogram.NumBins,1);
for i=1:Histogram.NumBins
x(i)=(ranges(i)+ranges(i+1))/2;
end
But I believe there should be some inbuilt method/property to do this.
So, is there some property/method which I can use to get the desired values?
1 Kommentar
Akzeptierte Antwort
Srivardhan Gadila
am 1 Mai 2020
Seems that from the documentation of histogram & Histogram Properties there isn't any built in property to get the values you are looking for.
binEdges = Histogram.BinEdges;
x = binEdges(1:end-1) + Histogram.BinWidth/2;
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Histograms finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!