Hi all, A=[1;3;5; 6]; for 1 to 100 iterations, if any element in array matches with the iteration,e.g .for 1st iteration A's 1st data is matching. else it should come out from the loop. Can u suggest me any idea?
Thanks

댓글 수: 1

Muruganandham Subramanian
Muruganandham Subramanian 2012년 5월 26일
for lm=1:100
if (~isempty(find(A == lm)))
%calcultion
end
end

댓글을 달려면 로그인하십시오.

 채택된 답변

Wayne King
Wayne King 2012년 5월 26일

0 개 추천

for nn = 1:8
if(any(A==nn)),
disp('hi');
else
disp('bye');
end
end
Obviously, replace disp('hi') with your calculation and I've just shown this up to an index of 8.

추가 답변 (1개)

Muruganandham Subramanian
Muruganandham Subramanian 2012년 5월 26일

0 개 추천

Hi wayne, This also works!!! for lm=1:100 if (~isempty(find(A == lm))) %calcultion end end

댓글 수: 1

Wayne King
Wayne King 2012년 5월 26일
Hi, sorry! I didn't see your comment above :)

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터 및 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!

Translated by