How to use matlab to achieve multiple cycles, as shown in Figure 1
1 次查看(过去 30 天)
显示 更早的评论
回答(2 个)
Walter Roberson
2022-12-8
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
2022-12-8
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
另请参阅
类别
在 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!