Store Output Values from All Iterations obtained by nested for loop and display minimum output and it correspond to which input values ?

1 visualizzazione (ultimi 30 giorni)
for c=[5 15]
for hh=[2 7]
ug=c/hh
end
end
  3 Commenti

Accedi per commentare.

Risposta accettata

Kumar Pallav
Kumar Pallav il 21 Mar 2022
Hi,
min=10000;
for c=[5 15]
for hh=[2 7]
ug=c/hh;
if ug<min
min=ug;
cAns=c;
hhAns=hh;
end
end
end
The above code will store the minimum in variable 'min' and the corresponding inputs in 'cAns' and 'hhAns'.
Hope it helps!

Più risposte (0)

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