Help Please Please i am stuck

here is the question
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
that is the codes i have for the problem.
n=10000; a=2; b=4 x=a+(b-a).*rand(10000,1); x=2*rand(1,n)+2*ones(1,n);% generate vector sample plot(x) xlabel('index');ylabel('Amplitude');grid pause [m,z]=hist(x);% calaclate and counts in bins and bins coodinates w=max(z)/4; % calculate bin width mm=m/(10000*w); % find probability in each bin v=linspace(min(x),max(x)); y=unifpdf(x,2,4);; % density function of Uniform distribution bar(z,mm) hold on plot (v,y) xlabel('randon Variable Value'); ylabel('Probability Density') hold off

4 Comments

Pls, format your question: http://www.mathworks.com/matlabcentral/answers/7885-tutorial-how-to-format-your-question
Also provide a meaningful title: http://www.mathworks.com/matlabcentral/answers/6200-tutorial-how-to-ask-a-question-on-answers-and-get-a-fast-answer
@Southie: Matt Fig pointed you to instruction about asking questions here already in your former tread: http://www.mathworks.com/matlabcentral/answers/10228-help-me-please
Now you show the code you have so far. As next step omit the "please", but use a descriptive subject. Then format your code. And finally ask a question.
We find 4 posts of you and Manu about this question. It would be more efficient to cooperate and formulate 1 _good_ question.
duplicate is at http://www.mathworks.com/matlabcentral/answers/10242-uniform-distribution-help-need

Sign in to comment.

Answers (2)

Jan
Jan on 26 Jun 2011
You find some detailed instructions here: Answers:10313.
Walter Roberson
Walter Roberson on 26 Jun 2011
Please do not open duplicate questions: it results in duplicate effort.

2 Comments

@Walter: You duplicate answers.
Unfortunately Comments don't generate email notifications :(

Sign in to comment.

Asked:

on 26 Jun 2011

Community Treasure Hunt

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

Start Hunting!