function [X]=sylvester(A,B,C,flag) // Generated by lmitool on Thu Feb 09 11:55:34 MET 1995 Mbound = 1e3;abstol = 1e-10;reltol = 1e-10; nu = 10; maxiters = 100; options=[Mbound,abstol,nu,maxiters,reltol]; ///////////DEFINE INITIAL GUESS AND PRELIMINARY CALCULATIONS BELOW [na,ma]=size(A);[nb,mb]=size(B) if ma<>na|mb<>nb then error("invalid dimensions");end X_init=zeros(ma,nb) /////////// XLIST0=list(X_init) XLIST=lmisolver(XLIST0,sylvester_eval,options) [X]=XLIST(:)Evaluation function
function [LME,LMI,OBJ]=sylvester_eval(XLIST) [X]=XLIST(:) /////////////////DEFINE LME, LMI and OBJ BELOW if flag=='c' then LME=A*X+X*B-C else LME=A*X*B-C end LMI=[];OBJ=[]Let's try a simple example with 3 states
A=[0,1,0;2,3,1;-1,-2,0]; B=[1,0;-2,1]; C=[1,2;0,1;1,-2]; [X]=sylvester(A,B,C,'c'); disp(X, 'X found is:') disp(A*X+X*B-C ,'Check: A*X+X*B-C =') X found is: ! 14.333333 3. ! ! - 7.3333333 - 1. ! ! - 1.3333333 - 1. ! Check: A*X+X*B-C = 1.0D-14 * ! - 0.0888178 0. ! ! - 0.2664535 0. ! ! 0. 0. !