-
Notifications
You must be signed in to change notification settings - Fork 0
/
sample1_yalmip.m
33 lines (31 loc) · 1.01 KB
/
sample1_yalmip.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
clear
format compact
% --- ステップ 1 ---------
A = [ 0 1 % 安定
-10 -2 ]
% --- ステップ 2 ---------
n = length(A);
P = sdpvar(n,n,'sy');
% --- ステップ 3 ---------
LMI = [];
ep = 1e-6;
M1 = P - eye(n);
M2 = P*A + A'*P;
LMI = [ LMI, M1 >= ep*eye(n) ];
LMI = [ LMI, M2 <= - ep*eye(n) ];
% --- ステップ 4 ---------
sol = solvesdp(LMI)
% ------------------------
eigen_A = eig(A) % A の固有値(実部がすべて負なら安定)
if sol.problem ~= 1 % LMI が可解なら
% --- ステップ 5 -------
P_feas = double(P)
disp('-----------------------------------------------')
disp('M1 の固有値:M1 > 0 なら M1 の固有値はすべて正')
disp('-----------------------------------------------')
eig(double( M1)) % M1 > 0 なら M1 の固有値はすべて正
disp('-----------------------------------------------')
disp('-M2 の固有値:M2 < 0 なら -M2 の固有値はすべて正')
disp('-----------------------------------------------')
eig(double(-M2)) % M2 < 0 なら -M2 の固有値はすべて正
end