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

1 view (last 30 days)
for c=[5 15]
for hh=[2 7]
ug=c/hh
end
end
  3 Comments

Sign in to comment.

Accepted Answer

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

More Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!