how can I find the maximum value of a parameter running within a loop

조회 수: 1 (최근 30일)
R@SH
R@SH 2021년 10월 16일
댓글: R@SH 2021년 10월 16일
Dear All,
I want to extract the maximum of a parameter in aloop through its various ieterations, something like below:
for i=1:100
A=f(i)
B=f(A,i)
C=f(B,i)
end
How can I find the maximum of C and also display corresponding A and B?
I would appreciate your response in advance.

채택된 답변

KSSV
KSSV 2021년 10월 16일
maxC = 0 ;
for i=1:100
A=f(i) ;
B=f(A,i) ;
C=f(B,i) ;
if C > maxC
maxC = C ;
Amax = A ;
Bmax = B ;
end
end
[maxC Amax Bmax]

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by