How to make multiple loops?
조회 수: 1 (최근 30일)
이전 댓글 표시
Mohamed Habiballa Abdelmoez
2018년 8월 25일
댓글: Mohamed Habiballa Abdelmoez
2018년 9월 24일
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
채택된 답변
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.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!