필터 지우기
필터 지우기

Find the theta1 and theta2 values that maximizes obj8Run

조회 수: 1 (최근 30일)
Andreas S
Andreas S 2020년 10월 11일
편집: KSSV 2020년 10월 12일
Hello everyone! I need some help to maximize my obj8Run function
My code is the following:
i=121:480;
MRn4=w4tilda.*MR4
mMRn4=mean(MRn4)
Sn4=cov(MRn4)
SRn4=M4/S4
Kp=(ret(i-4,1:10)+1).*(ret(i-3,1:10)+1).*(ret(i-2,1:10)+1).*(ret(i-1,1:10)+1)
Kp=Kp-1
Kp=normalize(Kp)
Lp= (bm(i-4,1:10)+1).*(bm(i-3,1:10)+1).*(bm(i-2,1:10)+1).*(bm(i-1,1:10)+1)
Lp=Lp-1;
Lp=normalize(Lp);
mlp=mean(Lp)
objSRun = @(theta) -((1+theta(1,1).*mr4+theta(1,2).*mlp)/N).*mMRn4./sqrt(((1+theta(1,1).*mr4+theta(1,2).*mlp)/N)*Sn4*((1+theta(1,1).*mr4+theta(1,2).*mlp)/N)');
w0 = [0.2,0.3] % initial guess
lb = zeros(1, 2)
ub = 1.5*ones(1, 2)
sol = fmincon(objSRun, w0, [], [], [], [], lb, ub)
When i run it i gives me the following error: Error using fmincon (line 635)
Supplied objective function must return a scalar value.
How can i solve it???
Thanks in advance!
  댓글 수: 1
VBBV
VBBV 2020년 10월 12일
Try the objSRun supplying theta as
% if true
% code
% end
objSRun = @(theta)
((1+theta.*mr4+theta.*mlp)/N).*mMRn4./sqrt(((1+theta.*mr4+theta.*mlp)/N)*Sn4*((1+theta.*mr4+theta.*mlp)/N)')

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Systems of Nonlinear Equations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by