Borrar filtros
Borrar filtros

Find the theta1 and theta2 values that maximizes obj8Run

1 visualización (últimos 30 días)
Andreas S
Andreas S el 11 de Oct. de 2020
Editada: KSSV el 12 de Oct. de 2020
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 comentario
VBBV
VBBV el 12 de Oct. de 2020
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)')

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Systems of Nonlinear Equations en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by