Effacer les filtres
Effacer les filtres

How to make multiple loops?

2 vues (au cours des 30 derniers jours)
Mohamed Habiballa Abdelmoez
Mohamed Habiballa Abdelmoez le 25 Août 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.

Réponse acceptée

Nicole Peltier
Nicole Peltier le 23 Sep 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.

Plus de réponses (0)

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!

Translated by