For loop for multiple scenarios
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Hello. I am trying to run caluclations for certain altitude, accelaration and Structure margin all at the same time.
How can I make my for loop calculate for the secnarios in the columns in the h_max and a_max and SM. I want the loop to calculate for h_max = 20000 a_max= 10 and SM = 1, then move to h_max = 20000 a_max= 10 and SM = 2 and so on. Please help!
%Maximum Altitude
h_max= 0.3048*[20000 20000 20000 2000 2000 10000 30000 10000 30000]; %m
a_max= [10 10 10 5 20 10 10 5 20]
SM = [1 2 3 2 2 2 2 1 3]
0 Commenti
Risposte (1)
James Tursa
il 11 Mag 2020
Modificato: James Tursa
il 11 Mag 2020
E.g.,
for k=1:numel(h_max)
% use h_max(k), a_max(k), and SM(k) in your code here
end
Or if they need to vary independently you could write nested loops. E.g.,
for k=1:numel(h_max)
for m=1:numel(a_max)
for n=1:numel(SM)
% use h_max(k), a_max(m), and SM(n) in your code here
end
end
end
Depending on what your code is, you might not need to use loops at all if there are only vectorized functions involved.
0 Commenti
Vedere anche
Categorie
Scopri di più su Loops and Conditional Statements in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!