nested for loop keeping i constant through all, until end of j's
1 view (last 30 days)
Show older comments
Hi, I am running a nested for loop
for i
for j
end
end
and I would like i=1 while j=1, 2, 3, 4, 5
i=2 j=1, 2, 3, 4, 5
i=3 j=1, 2, 3, 4, 5
...
i=5 j=1, 2, 3, 4, 5
is this an if or a while loop?
Thanks for any help!
2 Comments
Thorsten
on 17 Nov 2015
Edited: Thorsten
on 17 Nov 2015
i and j are very common loop counters, and they result in code that is readable and concise. I think it's ok to use them and use 1i for the complex unit, as advised by Matlab's help page:
For speed and improved robustness in complex arithmetic, use 1i and 1j instead of i and j.
See Also
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!