How do I write in For loop 2 condition

5 visualizzazioni (ultimi 30 giorni)
THANAPHAT CHONGSAN
THANAPHAT CHONGSAN il 27 Lug 2015
Risposto: Walter Roberson il 27 Lug 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

Risposte (1)

Walter Roberson
Walter Roberson il 27 Lug 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.

Categorie

Scopri di più su Loops and Conditional Statements in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by