How to use while true loop
19 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
i want solved exambls..
0 commentaires
Réponses (1)
Walter Roberson
le 19 Sep 2020
while true
x = rand();
if x < 0.1; break; end
end
1 commentaire
Walter Roberson
le 19 Sep 2020
As I posted recently when someone asked about "do while", the pattern in MATLAB is:
do while
some statements
if ~condition; break; end
end
Another example:
while true
a = randi(20); b = randi(20); c = randi(20);
if a^2+b^2 == c^2; break; end
end
This finds a random pythagorean triple.
Voir également
Catégories
En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!