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 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