How to extract the data points from histogram

71 Ansichten (letzte 30 Tage)
Kazi Main Uddin Ahmed
Kazi Main Uddin Ahmed am 21 Nov. 2019
Kommentiert: Image Analyst am 12 Apr. 2021
Hello, I have histogram figure (attached below). Now I need the bin and y axis values. How can I do that?
Thanks.

Akzeptierte Antwort

Image Analyst
Image Analyst am 21 Nov. 2019
Try this:
data = randn(1, 5000);
histObject = histogram(data)
grid on;
% Get the bin values into their own separate variable.
counts = histObject.Values
% Get the Y axis limits:
yl = ylim()
% Get the y Axis tick marks
yt = yticks
Don't use a semicolon. In the command window, you'll see the properties of the histogram including the BinEdges, Data, Counts, etc.
histObject =
Histogram with properties:
Data: [1×5000 double]
Values: [1 0 4 3 9 21 26 45 60 107 125 162 238 271 324 340 383 365 404 379 351 315 278 223 189 119 79 75 40 22 15 10 4 8 2 2 0 0 1]
NumBins: 39
BinEdges: [1×40 double]
BinWidth: 0.2
BinLimits: [-3.6 4.2]
Normalization: 'count'
FaceColor: 'auto'
EdgeColor: [0 0 0]
Show all properties
counts =
Columns 1 through 27
1 0 4 3 9 21 26 45 60 107 125 162 238 271 324 340 383 365 404 379 351 315 278 223 189 119 79
Columns 28 through 39
75 40 22 15 10 4 8 2 2 0 0 1
yl =
0 450
yt =
0 50 100 150 200 250 300 350 400 450
  2 Kommentare
Majed Alharthi
Majed Alharthi am 12 Apr. 2021
it tells me that: The variable h_pdf.Values does not exist.
can anyone help me?
Image Analyst
Image Analyst am 12 Apr. 2021
@Majed Alharthi, I think maybe you replied to the wrong post. My code has no such variable (h_pdf) and when I copy my code above and run it again, no such error gets thrown. Start a new question and attach your code that threw the error.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Kazi Main Uddin Ahmed
Kazi Main Uddin Ahmed am 22 Nov. 2019
thanks

Produkte


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by