How do I do a For Loop with two variables?
显示 更早的评论
I want the loop to do for i=1:1:41 and for j=1:1:41, that is, the loop runs using i=1 and j=1, then i=2 and j=2 etc.
When I try the below nested function I get an infinite loop! for i=1:1:41 for j=1:1:41 Function end end
Can anyone help? Thanks!
回答(1 个)
Then you dont need two for loops.
for i=1:41
j=i;
....do something
...
end
By the way, i and j are poor choice of variable names!
类别
在 帮助中心 和 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!