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!