program simulate tossing a coin

1 vue (au cours des 30 derniers jours)
reem
reem le 7 Avr 2011
Hello everybody please anyone answer me because I want to run this program but some error occurs,How can I solve this problem
N=input('Enter the number of simulations:')
for k=1:N
rand_number=rand;
if random_number<0.5
random_number(k,1)=1;
else
random_number(k,1)=0;
end
end
fprintf('\n')

Réponse acceptée

Walter Roberson
Walter Roberson le 7 Avr 2011
You assign to rand_number, but on the next line you test random_number
  6 commentaires
Walter Roberson
Walter Roberson le 7 Avr 2011
Yup. That's the only thing you request to print out in the code, other than the newline at the end. Your program is now functioning to the limits of all of the requirements you have indicated to us.
The variable name is corrected and the program no longer gives an error, so the matter is solved as far as the initial question is concerned.
You may perhaps now wish to go back and edit the question in order to include an explanation of what you need the program to _do_ and what it does instead, and to include an updated version of your code.
reem
reem le 7 Avr 2011
Thank you Walter for your fast response
Now,I solved the question
once again thank you so so much

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Get Started with MATLAB dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by