is it possible to optimize a function that have a matrix output with fmincon ?
4 views (last 30 days)
Show older comments
I want to minimize a function which the output is a matrix with an equality constraint. Matlab displays the following error message:
Error using fmincon (line 289) Aeq must have 440 column(s).
Error in objective2 (line 52) x = fmincon(fun,x0,A,b,Aeq,beq)
Below I write down my the example to solve:
A1=[-3 0;
0 -4];
B=[2;
1];
C=[1 0;
0.9 1;];
Ed=[0.7 0.7;
0.3 0.3];
Ef=[1;
0];
x0=zeros(22,20);
Hf=[zeros(2,11);
C*Ef zeros(2,10);
C*A1*Ef C*Ef zeros(2,9);
C*A1^2*Ef C*A1*Ef C*Ef zeros(2,8);
C*A1^3*Ef C*A1^2*Ef C*A1*Ef C*Ef zeros(2,7);
C*A1^4*Ef C*A1^3*Ef C*A1^2*Ef C*A1*Ef C*Ef zeros(2,6);
C*A1^5*Ef C*A1^4*Ef C*A1^3*Ef C*A1^2*Ef C*A1*Ef C*Ef zeros(2,5);
C*A1^6*Ef C*A1^5*Ef C*A1^4*Ef C*A1^3*Ef C*A1^2*Ef C*A1*Ef C*Ef zeros(2,4);
C*A1^7*Ef C*A1^6*Ef C*A1^5*Ef C*A1^4*Ef C*A1^3*Ef C*A1^2*Ef C*A1*Ef C*Ef zeros(2,3);
C*A1^8*Ef C*A1^7*Ef C*A1^6*Ef C*A1^5*Ef C*A1^4*Ef C*A1^3*Ef C*A1^2*Ef C*A1*Ef C*Ef zeros(2,2);
C*A1^9*Ef C*A1^8*Ef C*A1^7*Ef C*A1^6*Ef C*A1^5*Ef C*A1^4*Ef C*A1^3*Ef C*A1^2*Ef C*A1*Ef C*Ef zeros(2,1);
];
Hd=[zeros(2,22);
C*Ed zeros(2,20);
C*A1*Ed C*Ed zeros(2,18);
C*A1^2*Ed C*A1*Ed C*Ed zeros(2,16);
C*A1^3*Ed C*A1^2*Ed C*A1*Ed C*Ed zeros(2,14);
C*A1^4*Ed C*A1^3*Ed C*A1^2*Ed C*A1*Ed C*Ed zeros(2,12);
C*A1^5*Ed C*A1^4*Ed C*A1^3*Ed C*A1^2*Ed C*A1*Ed C*Ed zeros(2,10);
C*A1^6*Ed C*A1^5*Ed C*A1^4*Ed C*A1^3*Ed C*A1^2*Ed C*A1*Ed C*Ed zeros(2,8);
C*A1^7*Ed C*A1^6*Ed C*A1^5*Ed C*A1^4*Ed C*A1^3*Ed C*A1^2*Ed C*A1*Ed C*Ed zeros(2,6);
C*A1^8*Ed C*A1^7*Ed C*A1^6*Ed C*A1^5*Ed C*A1^4*Ed C*A1^3*Ed C*A1^2*Ed C*A1*Ed C*Ed zeros(2,4);
C*A1^9*Ed C*A1^8*Ed C*A1^7*Ed C*A1^6*Ed C*A1^5*Ed C*A1^4*Ed C*A1^3*Ed C*A1^2*Ed C*A1*Ed C*Ed zeros(2,2);
];
Ho=[C;C*A1;C*A1^2;C*A1^3;C*A1^4;C*A1^5;C*A1^6;C*A1^7;C*A1^8;C*A1^9;C*A1^10];
%--------------------------------------------------------------------------
fun = @(x)(x*Hd*Hd'*x')/(x*Hf*Hf'*x');
A = [];
b = [];
Aeq = Ho';
beq = 0;
x = fmincon(fun,x0,A,b,Aeq,beq)
x
3 Comments
Answers (0)
See Also
Categories
Find more on Applications in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!