How can I specify maximum and minimum of a parameter inside a loop

조회 수: 1 (최근 30일)
R@SH
R@SH 2021년 10월 17일
답변: KSSV 2021년 10월 17일
Dear All,
I would like to extract both the maximunm and minimum of a parameter which is obtained within a loop. something like below:
for i=1:50
A(i)=f(i);
B(i)=f(A);
C(i)=F(B);
end
How is it possible to specify both the maximum and minimum of C in its various iteratiuoins and also display the corresponding "A" and "B".

채택된 답변

KSSV
KSSV 2021년 10월 17일
minC = 0;
maxC = 0;
for i=1:50
A(i)=f(i);
B(i)=f(A);
C(i)=F(B);
if C > maxC
maxC = C ;
maxA = A ;
maxB = B
end
if C < minC
minC = C ;
minA = A ;
minB = B ;
end
end

추가 답변 (0개)

카테고리

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

태그

제품


릴리스

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by