Info
Cette question est clôturée. Rouvrir pour modifier ou répondre.
Storing output from a for loop into a matrix. When input value comes from .m script.
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I need to plot a histogram from my output data. I have written a script and know how to make this into a loop. However how can I get it into a matrix so i can make an Histogram.
kaart=5;
while kaart < 17
r = randi([1,10]);
if r==1
a= a+1;
r=11;
kaart=kaart+r;
else
kaart=kaart+r;
end
if kaart>21 && a > 0
kaart = kaart - 10;
a=a-1;
end
end
kaart
Above is the original script. I need to run this a 1000 times and make a histogram out of it. To run the for loop I have
for ii=1:1000;
Dealerscript;
end
However it does not allow me to make a histogram.
0 commentaires
Réponses (1)
KSSV
le 2 Déc 2016
kaart=5;
kaart1 = [] ;
while kaart < 17
r = randi([1,10]);
if r==1
a= a+1;
r=11;
kaart=kaart+r;
kaart1 = [kaart1 ; kaart] ;
else
kaart=kaart+r;
kaart1 = [kaart1 ; kaart] ;
end
if kaart>21 && a > 0
kaart = kaart - 10;
kaart1 = [kaart1 ; kaart] ;
a=a-1;
end
end
kaart1
May be you are looking for kaart values at the end. Check your a value, some times it goes to a condition where a is not defined.
0 commentaires
Cette question est clôturée.
Voir également
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!