blob: f56aa212e92fda9480b62900a6d51b50964965d6 (
plain)
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
% Do A PBH test on system. Given SYS returns:
%
% - Nr. of states
% - Nr. of stable states
% - Nr. of controllable states
% - Nr. of unstabilizable states
% - Nr. of observable states
% - Nr. of undetectable states
function [nx, nsta, nctrb, nustab, nobsv, nudetb] = pbhtest(sys)
nx = length(sys.A);
eigvals = eig(sys.A);
% Count number of stable states
nsta = 0;
for i = 1:nx
if real(eigvals(i)) < 0
nsta = nsta + 1;
end
end
% Check system controllability / stabilizability
Wc = ctrb(sys);
nctrb = rank(Wc);
if nctrb < nx
% Is the system at least stabilizable?
nustab = 0;
for i = 1:nx
if real(eigvals(i)) >= 0
% PBH test
W = [(sys.A - eigvals(i) * eye(nx)), sys.B];
if rank(W) < nx
nustab = nustab + 1;
end
end
end
end
% Check system observability / detectability
Wo = obsv(sys);
nobsv = rank(Wo);
if nobsv < nx
% is the system at least detectable?
nudetb = 0;
for i = 1:nx
if real(eigvals(i)) >= 0
% PBH test
W = [sys.C; (sys.A - eigvals(i) * eye(nx))];
if rank(W) < nx
nudetb = nudetb + 1;
end
end
end
end
end
|