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
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 Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!