WHILE loop with a condition on a vector?
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
SYED GILLANI
le 20 Oct 2016
Modifié(e) : James Tursa
le 20 Oct 2016
Hi all. I actually want to run the while loop until the absolute value of all the elements of a vector get equal to a certain value. just like below
while abs(vector_a(4,1) =< 0.00001 % run the instructions until absolute value of all elements of vector "a" are less than or equal to 0.00001
do the following instruction.........
end
0 commentaires
Réponse acceptée
James Tursa
le 20 Oct 2016
Modifié(e) : James Tursa
le 20 Oct 2016
Like this?
while any(~(abs(vector_a) <= 0.00001))
% do stuff
end
Or this (but will not get the same result if there are NaN's):
while any(abs(vector_a) > 0.00001)
% do stuff
end
0 commentaires
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!