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)
Show older comments
Vedant Chauhan
on 17 Mar 2022
Commented: Vedant Chauhan
on 23 Mar 2022
for c=[5 15]
for hh=[2 7]
ug=c/hh
end
end
3 Comments
Accepted Answer
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)
See Also
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!