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 个评论

请先登录,再进行评论。

采纳的回答

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 CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by