WHILE loop with a condition on a vector?

4 次查看(过去 30 天)
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

采纳的回答

James Tursa
James Tursa 2016-10-20
编辑:James Tursa 2016-10-20
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 个)

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by