Plotting Gamma Distribution, please help?

14 views (last 30 days)
Hydro
Hydro on 22 Sep 2014
Edited: Benabed Rabia on 2 Jan 2018
These are my code, however, i am not getting the plot.
X=1:100; % Duration of data
Data=rand(1,100); % randomly generated 100 years of data
Z=gamfit(Data); % fitting distribution for shape and scale factor
beta=2; % Shape factor
alpha=3; % scale factor
pdf=gampdf(X,alpha,beta); % pdf of the gamma distribution
Plot(pdf,X,'-');

Answers (5)

Youssef  Khmou
Youssef Khmou on 22 Sep 2014
It is correct, you just need to exchange pdf with X :
plot(x,pdf);
  2 Comments
Hydro
Hydro on 22 Sep 2014
still giving me the error that:
Index exceeded matrix dimension for this line.
pdf=gampdf(X,alpha,beta);
Youssef  Khmou
Youssef Khmou on 22 Sep 2014
the variables alpha and beta are in the system , change theirs names to Alpha, Beta for example.

Sign in to comment.


Mohammed
Mohammed on 22 Sep 2014
Edited: Mohammed on 22 Sep 2014
Change capital P-letter to small P-letter, MATLAB is case senstive!
plot(pdf,X,'-');

Hydro
Hydro on 22 Sep 2014
here is my plot which i dont think is a gamma distribution plot. my alpha is 3 and my beta is 409.

Hydro
Hydro on 22 Sep 2014
  2 Comments
Youssef  Khmou
Youssef Khmou on 22 Sep 2014
X=1:100; ALPHA=3; BETA=2; PDF=gampdf(X,ALPHA,BETA); plot(X,PDF);
Hydro
Hydro on 22 Sep 2014
Thanks Youssef, please have a look at my excel sheet which i am using for this problem...see if you are getting the same as i got up there...sorry for asking too much however, i really need to get this done as i am going to present it soon.
my x is years while alpha and beta were generated from the flow data.
Thanks dear

Sign in to comment.


Benabed Rabia
Benabed Rabia on 2 Jan 2018
Edited: Benabed Rabia on 2 Jan 2018
When i use plot command the graph just links the dots it does not give a curve, please help me! Thanks in advence

Community Treasure Hunt

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

Start Hunting!