While loop with all elements meeting the conditions
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Niklas Kurz
le 28 Oct 2022
Commenté : Niklas Kurz
le 28 Oct 2022
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 commentaires
Réponse acceptée
Davide Masiello
le 28 Oct 2022
Modifié(e) : Davide Masiello
le 28 Oct 2022
t = -100:200;
F = t;
indices = 1:100;
while all(F(indices)<0)
indices = indices + 1;
end
Plus de réponses (0)
Voir également
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!