Uniform distribution help need.

15 ビュー (過去 30 日間)
southie
southie 2011 年 6 月 25 日
Write a MATLAB script to do the following a. Create 10000 random variables uniformly distributed between 2 and 4. b. Create a histogram to approximate the actual probability density function. c. Superimpose the actual probability density function to the above histogram.
This is what i have done but have problem with creating the density function.
n=10000; x=2*rand[1,n]+2*ones[1,n]; plot(x) xlabel('index');ylabel('Amplitude');grid pause [m,z]=hist(x); w=max(z)/10; mm=m/(10000*w); v=linspace(min(x),max(x)); y=(1/Max(x)-Min(x))*ones(size(v)); bar(z,mm) hold on plot (v,y) xlabel('randon Variable Value'); ylabel('Probability Density') hold off
  2 件のコメント
bym
bym 2011 年 6 月 25 日
please format your code using the *{}Code* button
Andrew Newell
Andrew Newell 2011 年 6 月 25 日
See http://www.mathworks.com/matlabcentral/answers/7885-tutorial-how-to-format-your-question.

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

回答 (1 件)

Andrew Newell
Andrew Newell 2011 年 6 月 25 日
Hint: try
hist(x)

Community Treasure Hunt

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

Start Hunting!

Translated by