How to use matlab to find the optimized matrix with regarding to minimization of Frobenius norm
3 ビュー (過去 30 日間)
古いコメントを表示
I'm trying to solve a minimization problem whose purpose is to optimize a matrix whose square is close to another given matrix. but I have some problems to execute it by using matlab. The problem is illustrated as follows:

First question is how should I define the such an undetermined matrix when using optimization function in matlab;
Second question is if there is a specified toolbox to solve this problem?
2 件のコメント
採用された回答
Torsten
2016 年 2 月 25 日
編集済み: Torsten
2016 年 2 月 25 日
function main
G=zeros(4,4);
G(1,1)=0.48;
G(1,2)=0.24;
G(1,3)=0.16;
G(1,4)=0.12;
G(2,:)=G(1,:);
G(3,:)=G(1,:);
G(4,:)=G(1,:);
Aeq=zeros(4,12);
Aeq(1,1)=1.0;
Aeq(1,2)=1.0;
Aeq(1,3)=1.0;
Aeq(2,4)=1.0;
Aeq(2,5)=1.0;
Aeq(2,6)=1.0;
Aeq(3,7)=1.0;
Aeq(3,8)=1.0;
Aeq(3,9)=1.0;
Aeq(4,10)=1.0;
Aeq(4,11)=1.0;
Aeq(4,12)=1.0;
beq=ones(4,1);
lb=zeros(1,12);
ub=ones(1,12);
x0=ones(1,12)/3;
x = fmincon(@(x)obj(x,G),x0,[],[],Aeq,beq,lb,ub);
function val=obj(x,G)
Q(1,1)=x(1);
Q(1,2)=x(2);
Q(1,3)=0.0;
Q(1,4)=x(3);
Q(2,1)=x(4);
Q(2,2)=x(5);
Q(2,3)=x(6);
Q(2,4)=0.0;
Q(3,1)=0.0;
Q(3,2)=x(7);
Q(3,3)=x(8);
Q(3,4)=x(9);
Q(4,1)=x(10);
Q(4,2)=0.0;
Q(4,3)=x(11);
Q(4,4)=x(12);
val=sum(reshape((Q^2-G).^2,16,1));
end
Best wishes
Torsten.
11 件のコメント
CA Hau
2017 年 3 月 2 日
May I know if there are two constraints for the first rows (eg. q11+q12+q14 = 1 & q11-q12-q14 = 0.01) how should I modify the constraint? Thank you in advance for any enlightenment
Walter Roberson
2018 年 1 月 9 日
q11+q12+q14 = 1 & q11-q12-q14 = 0.01
would be
Aeq(1,1) = 1;
Aeq(1,2) = 1;
Aeq(1,3) = 1;
b(1,1) = 1;
Aeq(2,1) = 1;
Aeq(2,2) = -1;
Aeq(2,3) = -1;
b(2,1) = 0.01;
But remember that 0.01 does not have an exact representation in binary floating point, so the closest you can get to that second constraint is q11-q12-q14 = 0.01000000000000000020816681711721685132943093776702880859375
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Linear Least Squares についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!