How to extract the data points from histogram

조회 수: 72 (최근 30일)
Kazi Main Uddin Ahmed
Kazi Main Uddin Ahmed 2019년 11월 21일
댓글: Image Analyst 2021년 4월 12일
Hello, I have histogram figure (attached below). Now I need the bin and y axis values. How can I do that?
Thanks.

채택된 답변

Image Analyst
Image Analyst 2019년 11월 21일
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
Majed Alharthi
Majed Alharthi 2021년 4월 12일
it tells me that: The variable h_pdf.Values does not exist.
can anyone help me?
Image Analyst
Image Analyst 2021년 4월 12일
@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.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Kazi Main Uddin Ahmed
Kazi Main Uddin Ahmed 2019년 11월 22일
thanks

카테고리

Help CenterFile Exchange에서 Histograms에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by