How do I write in For loop 2 condition

5 ビュー (過去 30 日間)
THANAPHAT CHONGSAN
THANAPHAT CHONGSAN 2015 年 7 月 27 日
回答済み: Walter Roberson 2015 年 7 月 27 日
I would like to create script for For Loop in 2 factors
1. "A" very 0:0.2:40
2. "B" very 0:0.2:40
How do I create that
Could you please suggest method to solve that
Thank you

回答 (1 件)

Walter Roberson
Walter Roberson 2015 年 7 月 27 日
for A = 0:0.2:40
for B = 0:0.2:40
...
end
end
or
for AB = [0:0.2:40;0:0.2:40]
A = AB(1); B = AB(2);
...
end
or
Avals = 0:0.2:40;
Bvals = 0:0.2:40;
for K = 1 : length(Avals)
A = Avals(K);
B = Bvals(K);
...
end
I do not recommend using the AB version: it is obscure and would confuse most readers.

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by