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

1 回表示 (過去 30 日間)
for c=[5 15]
for hh=[2 7]
ug=c/hh
end
end
  3 件のコメント
Vedant Chauhan
Vedant Chauhan 2022 年 3 月 17 日
also i need to find for what value of c and hh, i get the minimum value of c/hh.

サインインしてコメントする。

採用された回答

Kumar Pallav
Kumar Pallav 2022 年 3 月 21 日
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!

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by