Following this question, I am trying to comprehend the functionality of MATLAB's ss() and tf2ss() functions and their differences. Consider the code below:
Kf = 0.2;
J = 0.02;
h2 = tf(1, [J Kf]);
dcm1 = ss(h2);
dcm2 = tf2ss(h2.Numerator{1}, h2.Denominator{1});
partially copied from here. Now I expect the dcm1 and dcm2 to be identical but here is what I get:
>> dcm1
dcm1 =
A =
x1
x1 -10
B =
u1
x1 8
C =
x1
y1 6.25
D =
u1
y1 0
Continuous-time state-space model.
>> dcm2
dcm2 =
-10
I would appreciate it if you could help me understand why am I getting two different results? how I can have identical results using the tf2ss() function? In other words, I want to create a dcm2 which is identical to dcm1 but using the tf2ss() function.
ssreturns a state-spacesystem, similar totfthey both return continuous systems inssandtfrepresentation respectively.ss2tfreturns the A, B, C, D matrices which are the result of converting the transfer functiontfinto its state-space representation.There's one caveat though, the state-space representation of a transfer function is not unique. It seems like
Matlabuses two different algorithms forssandtf2ss. You can verify that both systems return the same transfer function:dcm1 =
[A, B, C, D]
Now let's compare transfer functions: