% Define a stable matrix A
A = [-1 2 0;-3 -4 1;0 0 -2];

% Define a symmetric matrix P
P = sdpvar(3,3);

% semidefinite constraints for P (positive) and for A'*P+P*A (negative)
Constraints = [P >= 0, A'*P+P*A <= 0];

%constrain the trace of the matrix
Constraints = [Constraints, trace(P) == 1];

optimize(Constraints);
Pfeasible = value(P);

display('Constraints:');
display(Constraints);
display('Solution:');
display(Pfeasible);