How to use matlab to achieve multiple cycles, as shown in Figure 1
1 view (last 30 days)
Show older comments
Answers (2)
Walter Roberson
on 8 Dec 2022
ivals = 1:3;
jvals = 1:3;
numi = numel(ivals) ;
for idx = 1:numi
i = ivals(idx) ;
j = jvals(idx) ;
disp([i, j])
end
Steven Lord
on 8 Dec 2022
Another approach would be to take advantage of the fact that a for loop in MATLAB can iterate over columns of an array.
for ij = [1 2 3; 1 2 3]
disp(ij.')
end
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!