Problem in observibility and controlibility function ctrbf,obsvf

10 views (last 30 days)
After doing similarity transform, transfer function of a system taking controllable modes should be same as original. But it is not showing same results.
>> clear >> A = [-.5 1 0;-1 -.5 0; 0 1 0]
A =
-0.5000 1.0000 0
-1.0000 -0.5000 0
0 1.0000 0
>> b=[1;2;0]
b =
1
2
0
>> c =[0 0 1]
c =
0 0 1
>> [Abar,Bbar,Cbar,T,k]=ctrbf(A,b,c)
Abar =
0 0 0
0.4472 -0.5000 1.3416
0.6667 -0.7454 -0.5000
Bbar =
0
0.0000
2.2361
Cbar =
0.7454 0.6667 0
T =
-0.5963 0.2981 0.7454
0.6667 -0.3333 0.6667
0.4472 0.8944 0
k =
1 1 0
>> c*inv([s 0 0;0 s 0;0 0 s]-A)*b ??? Undefined function or variable 's'.
>> s=sym('s'); >> c*inv([s 0 0;0 s 0;0 0 s]-A)*b
ans =
(2*(4*s + 2))/(s*(4*s^2 + 4*s + 5)) - 4/(s*(4*s^2 + 4*s + 5))
>> Cbar*inv([s 0 0;0 s 0;0 0 s]-Abar)*Bbar
ans =
(4*s + 2)/(13510798882111488*(4*s^2 + 4*s + 5)) + 40/(20*s^2 + 20*s + 25)
>> T*A*T'
ans =
0 0 0
0.4472 -0.5000 1.3416
0.6667 -0.7454 -0.5000
>> Ac=[Abar(2,2) Abar(2,3);Abar(3,2) Abar(3,3)]
Ac =
-0.5000 1.3416
-0.7454 -0.5000
>> Bc=[Bbar(2,1);Bbar(2,3)] ??? Attempted to access Bbar(2,3); index out of bounds because size(Bbar)=[3,1].
>> Bc=[Bbar(2,1);Bbar(3,1)]
Bc =
0.0000
2.2361
>> Cc=[Cbar(1,2);Cbar(1,3)]
Cc =
0.6667
0
>> Cc=[Cbar(1,2) Cbar(1,3)]
Cc =
0.6667 0
>> Cc*inv([s 0 ;0 s]-Ac)*Bc
ans =
(4*s + 2)/(13510798882111488*(4*s^2 + 4*s + 5)) + 8/(4*s^2 + 4*s + 5)
>>
  1 Comment
Walter Roberson
Walter Roberson on 27 Mar 2011
It would be easier on readers if you were to cut out the places you know you made mistakes.

Sign in to comment.

Accepted Answer

Teja Muppirala
Teja Muppirala on 28 Mar 2011
This difference is just from round-off errors. Notice the second element in Bbar is 1.1102e-016. That is why you get that very large denominator (13510798882111488) in the symbolic expression
say Bbar(2) = 0, then everything works fine.
A = [-.5 1 0;-1 -.5 0; 0 1 0];
b=[1;2;0];
c =[0 0 1];
[Abar,Bbar,Cbar,T,k]=ctrbf(A,b,c)
syms s
Bbar(2) = 0;
c*( (s*eye(3)-A) \b)
Cbar*( (s*eye(3)-Abar) \Bbar)

More Answers (1)

Teja Muppirala
Teja Muppirala on 28 Mar 2011
Just a suggestion, but when doing symbolic calculations using 's' as a transfer function variable, you might want to explicitly make s a transfer function instead of just an ordinary symbolic variable.
s = tf('s')
instead of
s = sym('s')
This will allow you to actually treat those expressions like transfer functions.
G1 = c*( (s*eye(3)-A) \b) G2 = Cbar*( (s*eye(3)-Abar) \Bbar)
bode(G1) etc...
There is also a function MINREAL that you can use to cancel out poles and zeros.
minreal(G1,1e-6)

Categories

Find more on Symbolic Math Toolbox in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!