フィルターのクリア

How to make multiple loops?

2 ビュー (過去 30 日間)
Mohamed Habiballa Abdelmoez
Mohamed Habiballa Abdelmoez 2018 年 8 月 25 日
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.

採用された回答

Nicole Peltier
Nicole Peltier 2018 年 9 月 23 日
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.
  1 件のコメント
Mohamed Habiballa Abdelmoez
Mohamed Habiballa Abdelmoez 2018 年 9 月 24 日
thank you,

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by