规划问题fmincon报错显示Aeq must have 4 column(s),求解答。

3 views (last 30 days)
dutoga
dutoga on 28 Oct 2022
OrgR=importdata('股票和期货收益率.txt');
ER=mean(OrgR)
EV=cov(OrgR);
A=[-ER(1) -ER(2) -ER(3) -ER(4) -ER(5)];
b=0;
Aeq=[1.0 1.0 1.0 1.0 1.0];
Beq=1;
lb=[0;0;0;0;0];
ub=[1;1;1;1;1];
xmv0=[0.2;0.2;0.2:0.2;0.2];
options = optimset('largescale','off','MaxFunEvals',1000000,'MaxIte',1000000,'TolX',1e-4);
[xmv,fvalmv] = fmincon(@myf43,xmv0,A,b,Aeq,Beq,lb,ub,[],options);
另一个M文件:
function f=myf43(xmv)
f=0;
global EV;
for i=1:5
for k=1:5
f=f+EV(i,k)*xmv(i)*xmv(k);
end
end
end
报错:
错误使用 fmincon (line 281)
Aeq must have 4 column(s).
出错 mv43 (line 14)
[xmv,fvalmv] = fmincon(@myf43,xmv0,A,b,Aeq,Beq,lb,ub,[],options);
求大神解答,不胜感激!!!!

Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!