how to plot user defined pdf

this is my program:
n = input('enter the value of a ');
z=n-1;
e= exp(1);
y = ((sqrt(2*pi*z))*((z/e)^z));
display(y);
b= input ('enter the value of b');
for x=1:100
p= ((x^z) * (e^(-(x/b))))/(y*(b^n));
plot(x,p);
drawnow
end
please correct it

1 件のコメント

Jan
Jan 2012 年 7 月 12 日
編集済み: Jan 2012 年 7 月 12 日
Please read the instructions found at "About MATLAB Answers" to learn how to format your code and how to ask a good questions. Thanks.
When you ask for a correction, it would be a good idea to explain the problem. Do you get an error message or do the results differ from your expectations?

サインインしてコメントする。

回答 (1 件)

Wayne King
Wayne King 2012 年 7 月 12 日
編集済み: Wayne King 2012 年 7 月 12 日

0 投票

Well one problem you have is that you don't define i anywhere. Since i by default is the unit imaginary, you should probably use another variable.
Why are you using a loop, I think better to do something like
z = 9;
b = 2;
e= exp(1);
x = 1:100;
p = ((x.^z).* (e.^(-(x/b))))./(y*(b.^n));
plot(x,p)
Doing it the way you are in a loop, you are just plotting a single point in the plane.

2 件のコメント

Wayne King
Wayne King 2012 年 7 月 12 日
Now that you've edited your original post to fix your variable problem, my first comment does not apply, but what about the solution I gave you? Do you really need a loop?
Rahul
Rahul 2012 年 7 月 12 日
thank you bro, It worked

サインインしてコメントする。

カテゴリ

ヘルプ センター および File Exchange2-D and 3-D Plots についてさらに検索

タグ

質問済み:

2012 年 7 月 12 日

Community Treasure Hunt

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

Start Hunting!

Translated by