WHILE loop with a condition on a vector?

조회 수: 5 (최근 30일)
SYED GILLANI
SYED GILLANI 2016년 10월 20일
편집: James Tursa 2016년 10월 20일
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