# State space system gives different bode plot then transfer function matrix

77 views (last 30 days)
Wouter on 28 Oct 2014
Answered: Sandip Kumar on 29 Oct 2014
I have a discrete-time system with matrices A,B,C and D
I can either create a [state space system][1], sys1 = ss(A,B,C,D,Ts), of it or compute the [transfer function matrix][2], sys2 = C*inv(z*I- A)*B + D
However when I draw the bode plot of both systems, they are different while they should be the same.
What is going wrong here? Does anyone have a clue? I know btw that the bodeplot generated by sys1 and sys3 is correct.
Note that: my system is already discrete and no discritization is either being done by using
sys1 = ss(A,B,C,D,Ts);
or either
sys2 = C*inv(z*eye(3) - A)*B + D;
or either
[num,den] = ss2tf(A,B,C,D);
sys3 = tf(num,den,Ts);
The script
clear all;
close all;
clc;
Ts = 0.01;
z = tf('z',Ts);
% Discrete system
A = [0 1 0; 0 0 1; 0.41 -1.21 1.8];
B = [0; 0; 0.01];
C = [7 -73 170];
D = 1;
% Set as state space
sys1 = ss(A,B,C,D,Ts);
% Compute transfer function
sys2 = C*inv(z*eye(3) - A)*B + D;
% Compute the actual transfer function
[num,den] = ss2tf(A,B,C,D);
sys3 = tf(num,den,Ts);
% Show bode
bode(sys1,'b',sys2,'r--',sys3,'g--');
[1]: http://en.wikibooks.org/wiki/Control_Systems/MIMO_Systems#State-Space_Representation
[2]: http://en.wikibooks.org/wiki/Control_Systems/MIMO_Systems#Transfer_Function_Matrix

Sandip Kumar on 29 Oct 2014
The sys2 created is not the minimal realization of the system, and if you perform minimal realization you will get back the same system:
>> minreal(sys2)
ans =
z^3 - 0.1 z^2 + 0.48 z - 0.34
-----------------------------
z^3 - 1.8 z^2 + 1.21 z - 0.41
Sample time: 0.01 seconds
Discrete-time transfer function.
which is the same as the sys3
>> sys3
sys3 =
z^3 - 0.1 z^2 + 0.48 z - 0.34
-----------------------------
z^3 - 1.8 z^2 + 1.21 z - 0.41
Sample time: 0.01 seconds
Discrete-time transfer function.
And I understand this is what you are witnessing:
In addition, converting back and forth between model types can introduce additional states or orders, or introduce numeric inaccuracies. For example, conversions to state space are not uniquely defined, and are not guaranteed to produce a minimal realization for MIMO models.
Thanks, Sandip