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

3 vues (au cours des 30 derniers jours)
dutoga
dutoga le 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);
求大神解答,不胜感激!!!!

Réponses (0)

Catégories

En savoir plus sur 非线性方程组 dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!