MATLAB: Do state space and its equivalent transfer function models yield different step responses

Control System Toolboxcontrol systemsstate-space

I have written a MATLAB code to build a transfer function by interconnecting dynamic blocks. When I run the m-file, I get different step responses from the state-space model and its transfer function equivalent. The system is SISO type. May you advise?
Here is the code:
G_1 = tf([160], [1]); G_2 = tf([1], [1 1 0]); H = tf([1 0], [1]);
G_1.InputName = 'e'; G_1.OutputName = 'gain_out';
G_2.InputName = 'p_in'; G_2.OutputName = 'output';
H.InputName = 'output'; H.OutputName = 'sense_out';
sum1 = sumblk('e = input - output'); sum2 = sumblk('p_in = gain_out - sense_out');
sys_ss = connect(G_1, G_2, H, sum1, sum2, 'input', 'output');
[num den] = ss2tf(sys_ss.A, sys_ss.B, sys_ss.C, sys_ss.D); sys_tf = tf(num, den);
step(sys_ss), grid on; figure; step(sys_tf), grid on;

Best Answer

Hi there,
Examine the state-space model sys_ss:
>> sys_ss
Note that it has a non-unity E matrix. This happens because your H, a pure derivative, is improper. The connect command represents that block as a two-state ss with a non-unity E matrix - a descriptor ss. When connect builds the interconnected system, it preserves those states, so it yields a descriptor system.
And that means that your call to ss2tf, which only uses A,B,C, and D, is missing part of the dynamics of the system. sys_tf doesn't represent the same dynamics as sys_ss.
This is one of the reasons that ss2tf is not a great command to use when converting from ss to tf form. Try this instead:
>> sys_tf = tf(sys_ss)
This time when you plot the step responses, they match up. Also, tf removes those two extra states.
You can also reduce and simplify sys_ss into explicit form (E = 1) using the 'explicit' option of the ss command:
>> sys_ss_ex = ss(sys_ss,'explicit')
Now all of the system dynamics are described by A,B,C, and D.
For more information about explicit and descriptor state-space models, see the reference page for ss.
>> doc ss
Hope this helps!