フィルターのクリア

Find the theta1 and theta2 values that maximizes obj8Run

2 ビュー (過去 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 Center および File ExchangeMATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by