How to use matlab to achieve multiple cycles, as shown in Figure 1

3 ビュー (過去 30 日間)
bing zhu
bing zhu 2022 年 12 月 8 日
コメント済み: bing zhu 2022 年 12 月 8 日

回答 (2 件)

Walter Roberson
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
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
1 1 2 2 3 3

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

製品


リリース

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by