Help Please Please i am stuck
Show older comments
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
Oleg Komarov
on 26 Jun 2011
Pls, format your question: http://www.mathworks.com/matlabcentral/answers/7885-tutorial-how-to-format-your-question
Andrew Newell
on 26 Jun 2011
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
Jan
on 26 Jun 2011
@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.
Walter Roberson
on 26 Jun 2011
duplicate is at http://www.mathworks.com/matlabcentral/answers/10242-uniform-distribution-help-need
Answers (2)
Jan
on 26 Jun 2011
1 vote
Walter Roberson
on 26 Jun 2011
0 votes
Please do not open duplicate questions: it results in duplicate effort.
You can edit your previous question, http://www.mathworks.com/matlabcentral/answers/10242-uniform-distribution-help-need
2 Comments
Jan
on 26 Jun 2011
@Walter: You duplicate answers.
Walter Roberson
on 27 Jun 2011
Unfortunately Comments don't generate email notifications :(
Categories
Find more on Uniform Distribution (Continuous) in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!