% sos_decomposition2.m

% 2011/01/26   H. Ichihara

clear all;

% polynomial
sdpvar x1 x2;
p = 2*x1^4+3*x1^2*x2^2+2*x1*x2^3+4*x2^4;

% SOS set
Fs = sos(p);

% call solver
options = sdpsettings;
options.solver = 'sedumi'; % 'lmilab','sdpt3'
if strcmp(options.solver,'lmilab')
 % If you use LMILAB, you may need to change 'options.sos.model'.
 options.sos.model = 2;
end
[sol,monos,Q,resi] = solvesos(Fs,[],options)

% check set
for resii = resi'
 if resii > 1e-6
  disp('Infeasible!!')
 end
end

% EOF