how to run a loop according to two different index at the same time?
7 次查看(过去 30 天)
显示 更早的评论
For example:
i=[0 1 3 6 10]
j=[1 3 6 10 15]
Normally, when we use
'for index1=i
for index2=i
....
end
end'
then Matlab will firstly set i=0 and then run all the vaules from 1 to 15 in index2, and then goes back to i=1.
However, in my problem, I require that i and j to be executed simultaneously, like: when i=0, j=1, then i=1, j=3.
Anyone can tell me how to do with it?
many thanks
0 个评论
采纳的回答
per isakson
2014-12-25
编辑:per isakson
2014-12-25
One way:
ii = [0,1,3,6,10];
jj = [1,3,6,10,15];
for ix = 1 : length(ii)
ii(ix)
jj(ix)
end
4 个评论
更多回答(0 个)
另请参阅
类别
在 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!