Weibull distribution plot x-axes scale is wrong

2 ビュー (過去 30 日間)
Dora de Jong
Dora de Jong 2021 年 10 月 21 日
回答済み: Star Strider 2021 年 10 月 21 日
I am having problems with plotting a Weibull distribution for the variable: 'Cont_Wh_Wp'.
The x-axes shows weird scale, see figure below.
If I plot a histogram and and divide the x-axes by the number of point(662) the frequency on the x-axis seems to be better, see figure below.
The schape of both graphs are the same, but the x-axes is different. Below is my script where I plot the two grapgh.
%% Weibull
[parmHat, parmCI]=wblfit(Cont_Wh_Wp);
scale= parmHat(1);
shape=parmHat(2);
figure(1)
X=linspace(min(Cont_Wh_Wp),max(Cont_Wh_Wp));
plot(X,wblpdf(X,parmHat(1),parmHat(2)))
%% Histogram
figure(2)
histogram(Cont_Wh_Wp,80)
Can someone help me with getting the x-axis on the right scale for the Weibull plot?

回答 (1 件)

Star Strider
Star Strider 2021 年 10 月 21 日
Try something like this —
%% Weibull
[parmHat, parmCI]=wblfit(Cont_Wh_Wp);
scale= parmHat(1);
shape=parmHat(2);
figure(1)
X=linspace(min(Cont_Wh_Wp),max(Cont_Wh_Wp));
plot(X,wblpdf(X,parmHat(1),parmHat(2)))
xl = xlim; % Get X-Axis Limits (Range)
%% Histogram
figure(2)
histogram(Cont_Wh_Wp,80)
xlim(xl) % Set X-Axis Limits (Range) To The First Plot Values
.

タグ

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by