there is a way that if clause it is execute
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Here it is a piece of code:
x = rand;
if x < 1E-6
do-something
end
if I execute this piece of block in loop, the program never execute if clause because x is always bigger. how can I enter in that block?
0 Commenti
Risposta accettata
per isakson
il 20 Set 2012
Modificato: per isakson
il 20 Set 2012
Try this:
for ii = 1 : 1e7
x = rand;
if x < 1E-6
disp( 'do-something' )
end
end
do-something
do-something
do-something
do-something
do-something
do-something
do-something
Thus, in this case it was executed seven times. (R2012a,64bit,Win7)
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Clusters and Clouds in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!