blob: 546bbc60c03246e3af756f8a8cae49cd74fd3ddc (
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 a state space model 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);
nustab = 0;
if nctrb < nx
% Is the system at least stabilizable?
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);
nudetb = 0;
if nobsv < nx
% is the system at least detectable?
for i = 1:nx
if real(eigvals(i)) >= 0
% PBH test
W = [(sys.A' - eigvals(i) * eye(nx)), sys.C'];
if rank(W) < nx
nudetb = nudetb + 1;
end
end
end
end
end
|