필터 지우기
필터 지우기

histogram function, bins and edges

조회 수: 50 (최근 30일)
Timo Strotbaum
Timo Strotbaum 2018년 8월 1일
댓글: Adam Danz 2023년 4월 18일
Hi everybody,
I´m trying to plot some histogramms of different vectors, and therefore i need to determine as well the number of bins as the Edges for the histogramm. when changing either of them, Matlab changes the other one automatically, is there a way i can determine these numbers by myself?
h = histogram(v,"NumBins",100,'Normalization','probability', "BinEdges", [5.4536e+03:1.2093e+05])
I tried to put everything in as input arguments, but the histogramm has different values:
h =
Histogram with properties:
Data: [66001×1 double]
Values: [1×115476 double]
NumBins: 115476
BinEdges: [1×115477 double]
BinWidth: 1
BinLimits: [5.4536e+03 1.2093e+05]
Normalization: 'probability'
FaceColor: 'auto'
EdgeColor: [0 0 0]
  댓글 수: 2
KSSV
KSSV 2018년 8월 1일
Why do you feel they are different? It is acting accordingly to your input.
Timo Strotbaum
Timo Strotbaum 2018년 8월 1일
Because in said NumBins should be 100, not 115476

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

채택된 답변

KSSV
KSSV 2018년 8월 1일
If you want 100 bins use:
h = histogram(v,"NumBins",100,'Normalization','probability', "BinEdges", linspace(5.4536e+03,1.2093e+05,101)) ;
  댓글 수: 1
Adam Danz
Adam Danz 2023년 4월 18일
In this case, "NumBins" is being ignored. Either use NumBins or BinEdges.
Here's an example where NumBins=2 but there are 100 bins defined by BinEdges.
h = histogram(rand(1,1000), "NumBins", 2, "BinEdges", linspace(0, 1, 101));

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

추가 답변 (0개)

카테고리

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

태그

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by