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

1 vue (au cours des 30 derniers jours)
for c=[5 15]
for hh=[2 7]
ug=c/hh
end
end
  3 commentaires
Vedant Chauhan
Vedant Chauhan le 17 Mar 2022
also i need to find for what value of c and hh, i get the minimum value of c/hh.

Connectez-vous pour commenter.

Réponse acceptée

Kumar Pallav
Kumar Pallav le 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!

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by