How do I write in For loop 2 condition

5 views (last 30 days)
THANAPHAT CHONGSAN
THANAPHAT CHONGSAN on 27 Jul 2015
Answered: Walter Roberson on 27 Jul 2015
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

Answers (1)

Walter Roberson
Walter Roberson on 27 Jul 2015
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.

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!