While loop stops before meeting conditions
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Thibaut
am 6 Apr. 2020
Beantwortet: Srivardhan Gadila
am 10 Apr. 2020
Hi guys,
I am using a while loop with 3 conditions. Here it is :
while (X<90 && Y<90 && Z<90)
...
Or the program stop when I reach these values :
X = 87.55
Y = 87.58
Z = 93.21
Only one condition is true, so why the program stops ?
Thank you very much for your help !
3 Kommentare
Torsten
am 6 Apr. 2020
As written, the program leaves the while loop if at least one condition is false - and this is the case for Z.
Akzeptierte Antwort
Srivardhan Gadila
am 10 Apr. 2020
As mentioned by @Torsten, the program remains in the while loop "while (X<90 && Y<90 && Z<90)" only when the values of all the variables X, Y & Z are less than 90. Since the value of Z is 93.21 which is greater than 90, hence the program exits the while loop.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Environment and Settings finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!