Help Please Please i am stuck
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Jan
le 26 Juin 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
le 26 Juin 2011
duplicate is at http://www.mathworks.com/matlabcentral/answers/10242-uniform-distribution-help-need
Réponses (2)
Walter Roberson
le 26 Juin 2011
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 commentaires
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!