How to make multiple loops?
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Mohamed Habiballa Abdelmoez
il 25 Ago 2018
Commentato: Mohamed Habiballa Abdelmoez
il 24 Set 2018
Hi, in my code there are two while loops but when I run the program only on work at a time. my question is: How to make all the loops work together at any moment?
this a sample code for understanding the question:
%%first while loop
count = 0;
while count ~= 1
%%*statements*
pause(1)
end
%%second while loop
count = 0;
while count ~= 1
%%*different_statements*
pause(1)
end
As you can see the loop made to be infinite loop, so when I used two of them in one code only one work at a time.
0 Commenti
Risposta accettata
Nicole Peltier
il 23 Set 2018
The two sets of statements (where you put %%*statements* and %%*different_statements*) need to be in the same while loop. The code in the second loop won't start until the first loop terminates (and as you pointed out, the first loop will not terminate). If you want the sets of statements to happen together, there seems to be no reason why you would need two loops.
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Loops and Conditional Statements 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!