Rev | Line | |
---|
[37] | 1 | clc |
---|
| 2 | echo on |
---|
| 3 | %********************************************************* |
---|
| 4 | % |
---|
| 5 | % Lyapunov analysis using semidefinite programming |
---|
| 6 | % |
---|
| 7 | %********************************************************* |
---|
| 8 | |
---|
| 9 | % Create a stable matrix |
---|
| 10 | A = [-1 2;0 -2]; |
---|
| 11 | pause % Strike any key to continue. |
---|
| 12 | |
---|
| 13 | % Create symmetric matrix (full syntax) |
---|
| 14 | P = sdpvar(2,2,'symmetric'); |
---|
| 15 | pause % Strike any key to continue. |
---|
| 16 | |
---|
| 17 | % Add SETs for stability |
---|
| 18 | F = set(P>eye(2)) + set(A'*P+P*A<0) |
---|
| 19 | pause % Strike any key to continue. |
---|
| 20 | |
---|
| 21 | % Find feasible solution, minimize trace(P) |
---|
| 22 | solution = solvesdp(F,trace(P)); |
---|
| 23 | pause % Strike any key to continue. |
---|
| 24 | |
---|
| 25 | % Extract numerical solution |
---|
| 26 | P_feasible = double(P); |
---|
| 27 | |
---|
| 28 | % Check solution |
---|
| 29 | eig(P_feasible) |
---|
| 30 | eig(A'*P_feasible+P_feasible'*A) |
---|
| 31 | pause % Strike any key to continue. |
---|
| 32 | |
---|
| 33 | % Checking the constraints can also be done with |
---|
| 34 | checkset(F) |
---|
| 35 | |
---|
| 36 | pause % Strike any key to continue. |
---|
| 37 | echo off |
---|
Note: See
TracBrowser
for help on using the repository browser.