Find the theta1 and theta2 values that maximizes obj8Run
조회 수: 1 (최근 30일)
이전 댓글 표시
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
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 Center 및 File Exchange에서 Systems of Nonlinear Equations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!