How to save all runs in the while loop
Afficher commentaires plus anciens
I'm trying to figure out how to save every point in my while loop in order to graph it in the comet function. My code looks like:
n = 1
score = 0
while n < 100
n = n + 1
x = randi(2);
if (x == 1)
score = score + 1;
elseif(x == 2)
score = score - 1;
end
end
comet(score)
All it currently does is show what score ends as and i what to plot every point before then as well. What should i change it to to make it keep and plot every prevouis score?
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Physics dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!