Converting a weibull figure to a histogram

조회 수: 4 (최근 30일)
Youssef Chehade
Youssef Chehade 2021년 3월 17일
답변: Jeff Miller 2021년 3월 17일
I created a weibull distribution based on hours of the day. I would like to have a histogram to further show these results. How can I obtain the histogram?
The code for the weibull distribution is:
x=0:1:23;
y=wblpdf(x,3,2);
y_new=round(4000*y);
y_new=circshift(y_new,16);
figure(1)
plot(x,y_new)
I tried using histogram(y_new) and histfit(y_new), even adjusting number of bins, but the figures I got were very different
Any tips please?

채택된 답변

Jeff Miller
Jeff Miller 2021년 3월 17일
histogram takes a list of data values (your x's) and tabulates how often each occurs. if you don't already have data values, you might generate some randomly, e.g.
sample_data = wblrnd(3,2,10000,1);
histogram(sample_data); % 'normalization','pdf');
The extra (now commented) parameters on the histogram command will put the histogram heights on the same scale as the pdf values from wblpdf.

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by