I'm starting to use Yalmip, and I'd like to implement an example taken from the book of Prof. Boyd "Linear Matrix Inequalities in System and Control Theory". Specifically, I'd like to implement an example of what illustrated in Sec. 3.1 (pag 37) of the book, about the scaling of a rectangular matrix M via diagonal, PSD matrices.
I just would like to know whether I'm doing anything wrong, because according to the syntax of Yalmip, it should be ok.
since I want to minimize gamma^2, I defined a variable gam2 > 1, which should be equivalent. For the rest I´m using the same nomenclature of the book. Am I doing anything weird here? Thanks a lot,
yalmip('clear');
% defining the matrix to scale
M = [100 23 2; 40 1 8; 6 .0004 1; 5000 2 1];
% check the condition number
cond(M);
% define the dimensions of the matrices P and Q
dim = size(M);
p = dim(1);
q = dim(2);
% define in Yalmip the matrices P and Q, theymust be PSD matrices
P = sdpvar(p,p,'diagonal');
Q = sdpvar(q,q,'diagonal');
% define the scalar gamma^2. Since it is a condition number, it has to be equal or greater than 1
gam2 = sdpvar(1,1);
% assign the LMI conditions: P, Q PSD, and Q<=M' P M <= gamma^2*Q
F = [P>0, Q>0, gam2>1,Q<=M'*P*M,M'*P*M<=gam2*Q];
% solve
optimize(F,gam2)
% check the values
value(gam2)
value(Q)
value(P)
% extract the matrices L and R
L = chol(value(P),'lower');
R = chol(Qi,'lower');
% check the new condition number
cond(L*M*R)