While loop with all elements meeting the conditions
조회 수: 1 (최근 30일)
이전 댓글 표시
How do I set a while loop that runs until all elements meet the condition? For instance:
t = -100:200;
F = t;
indices = 1:100;
while F(indices) < 0 %
indices = indices + 1;
end
This while-loop only will run, until one of the elements of F(indices) will be creater than 0. However I wish it will run until all of the elements will meet the condition. How to implement this?
댓글 수: 0
채택된 답변
Davide Masiello
2022년 10월 28일
편집: Davide Masiello
2022년 10월 28일
t = -100:200;
F = t;
indices = 1:100;
while all(F(indices)<0)
indices = indices + 1;
end
추가 답변 (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!