Matlab Code for Observability Matrix Step by Step

A=[-1 2 -1 -1 2 3;5 7 -1 -2 0 -1;1 -8 -1 -1 0 2;-2 5 1 1 -1 -3;1 2 5 6 9 0;1 -2 5 -6 2 6]
C=[1 6 5 1 5 -8; 1 -5 -9 2 1 9;-2 5 7 5 7 3]
O=obsv(A,C)
rank(O(1:4,:))
rank(O(1:5,:))
rank(O(1:6,:))
rank(O(1:7,:))
%rank(O(1:7,:)) means C1A2 so rho1=2
rho1=2
0020
rank(O(1:8,:))
rho2=2
%rank(O(1:8,:)) means C2A2 so rho2=2
rho3=6-rho1-rho2
On=[C(1,:); C(1,:)*A ;C(2,:); C(2,:)*A; C(3,:) ;C(3,:)*A]
M=inv(On)
PI=[M(:,2) A*M(:,2) M(:,4) A*M(:,4) M(:,6) A*M(:,6)]
P=inv(PI)
AH=P*A*PI
CH=PI*C

SIMULATION & RESULT
Taking A matrix 6*6 i.e
A=[-1 2 -1 -1 2 3;5 7 -1 -2 0 -1;1 -8 -1 -1 0 2;-2 5 1 1 -1 -3;1 2 5 6 9 0;1 -2 5 -6 2 6]

A=
-1 2 -1 -1 2 3
5 7 -1 -2 0 -1
1 -8 -1 -1 0 2
-2 5 1 1 -1 -3
1 2 5 6 9 0
1 -2 5 -6 2 6
Taking C matrix 3*6 i.e
C=[1 6 5 1 5 -8; 1 -5 -9 2 1 9;-2 5 7 5 7 3]
C =
1 6 5 1 5 -8
1 -5 -9 2 1 9
Generating Observability Matrix by using command
O=obsv(A,C)
Observability Matrix is actually

[C1
C2
C3

C1A
C2A
C3A
C1A2
C2A2
C3A2
C1A3
C2A3
C3A3
C1A4
C2A4
C3A4
C1A5
C2A5
C3A5]

-2 5 7 5 7 3

O =
1 6 5 1 5 -8
1 -5 -9 2 1 9
-2 5 7 5 7 3

29 35 -26 61 30 -44

-29 33 65 -28 27 38

34 8 45 14 60 6

-16 964 -47 432 179 -447

380 -509 228 -196 289 322

89 -58 257 243 606 178

3657 10504 -1809 2323 253 -5084

-1694 -5673 2760 16 4201 4625

176 -213 3875 2581 5745 1178

37577 117603 -34184 11489 -2900 -40624

-15117 -65947 48753 7752 43655 33813

4395 -10100 33358 26358 51832 7816

449752 1304740 -327127 -766 -43683 -351451

-203901 -823443 427403 165062 422535 297724

-14605 -108952 296945 272901 464552 57823

Checking Rank to decide rho’s

rank(O(1:4,:))
rank(O(1:5,:))
rank(O(1:6,:))
rank(O(1:7,:))
As in 6 and 7 ranks are same so extracting rho from 7th row that is C1A2 so here rho1=2
By same method extracting rho 2 and rho 3 values
ans =
4
ans=
5
ans =
6
ans =
6
rho1 =
2
ans =
6
rho2 =

2
rho3 =

2

Observability Index Matrix “On” by using command

On=[C(1,:); C(1,:)*A ;C(2,:); C(2,:)*A; C(3,:) ;C(3,:)*A]
On =


1 6 5 1 5 -8


29 35 -26 61 30 -44


1 -5 -9 2 1 9


-29 33 65 -28 27 38


-2 5 7 5 7 3


34 8 45 14 60 6

For P-1 finding M Matrix that is the inverse of On Matrix by using command


M=inv(On)

M =


-0.2471 0.0294 -0.1145 0.0218 -0.2025 0.0216


-0.1359 0.0341 -0.0508 0.0360 -0.1607 -0.0024


-0.1078 -0.0029 -0.1137 -0.0046 0.0535 0.0082


-0.1061 0.0025 -0.0671 -0.0145 0.1400 -0.0011


0.2801 -0.0211 0.1748 -0.0120 0.0686 -0.0016


-0.1634 0.0146 -0.0226 0.0175 -0.0520 0.0049


Now Finding PI that is P-1 by using command


PI=[M(:,2) A*M(:,2) M(:,4) A*M(:,4) M(:,6) A*M(:,6)]
PI =


0.0294 0.0408 0.0218 0.0978 0.0216 -0.0220


0.0341 0.3696 0.0360 0.3771 -0.0024 0.0806


-0.0029 -0.2141 -0.0046 -0.2123 0.0082 0.0432


0.0025 0.0887 -0.0145 0.0770 -0.0011 -0.0610


-0.0211 -0.0918 -0.0120 -0.1245 -0.0016 0.0365


0.0146 -0.0228 0.0175 0.0942 0.0049 0.0999

Now computting P matrix by just inversing PI Matrix


P=inv(PI)

P =


-24.6392 16.5749 64.3282 30.7115 -63.3855 -4.6835


1.0000 6.0000 5.0000 1.0000 5.0000 -8.0000


11.0558 -8.2167 -34.6554 -69.9949 -11.3790 -14.5166


1.0000 -5.0000 -9.0000 2.0000 1.0000 9.0000


60.2943 2.0630 -14.3502 22.8711 91.0462 -1.5354


-2.0000 5.0000 7.0000 5.0000 7.0000 3.0000

So to compute AH matrix just multiplying


“P”, “A” and “PI”


AH=P*A*PI


AH =


0.0000 -44.6274 0.0000 -29.3929 -0.0000 -58.1851


1.0000 23.3472 0.0000 18.3714 -0.0000 -5.9603


0.0000 -0.1805 0.0000 12.8319 0.0000 -7.3240


-0.0000 -8.7343 1.0000 -6.1276 -0.0000 12.5969


0.0000 73.0422 0.0000 49.1644 -0.0000 71.3838


0.0000 -9.6939 0.0000 -9.0396 1.0000 3.780

So to compute CH matrix just multiplying


“PI” and “C”.


CH=PI*C

CH =


0.0000 1.0000 0.0000 0.0000 0.0000 0.0000


-0.0000 0.0000 -0.0000 1.0000 0.0000 0.0000


0.0000 0.0000 0.0000 0.0000 -0.0000 1.0000

Comments

Popular Posts