Regsrding for loop with array
1 次查看(过去 30 天)
显示 更早的评论
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
采纳的回答
Wayne King
2012-5-26
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.
0 个评论
更多回答(1 个)
另请参阅
类别
在 Help Center 和 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!