Weibull distribution plot x-axes scale is wrong

4 views (last 30 days)
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?

Answers (1)

Star Strider
Star Strider on 21 Oct 2021
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
.

Tags

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!