How to convert a transfer function into state space representation?
Afficher commentaires plus anciens
I was trying to convert a transfer function into state space representation, but the matrices in the output are not quiet correct. The numbers are flipped like how in B 0 should be up and 1 should be down, or in C where 2 should be right and 3 should be left. How can I fix this issue?

Réponses (2)
The state space realization of a transfer function is not unique. In fact, there are infinitely many state space realizations to choose from.
num = [0 3 2];
den = [1 4 4];
The Control System Toolbox uses one methodology
G = ss(tf(num, den))
and the Signal Processing Toolbox uses another
[A,B,C,D] = tf2ss(num,den)
Each realization has the same transfer function
tf(G)
[b,a] = ss2tf(A,B,C,D)
Any other realization can be obtained via similarity transformation. The CST provides a function ss2ss to do that
ss2ss(ss(A,B,C,D),[0 1;1 0])
tf(ans)
1 commentaire
It appears that the Control System Toolbox finds a realization with a balance(d) A-matrix, at least in this case. I speculate that such a realization has better numerical properties for operations that are typically performed on such models.
Define a simple transfer function
num = [1,2,3];
den = [1,11,12,13];
The Signal Processing Toolbox returns a realization in a canonical form (offhand, I forget what this form is called). It's easy to convert a transfer function into a canonical form and canonical forms are useful from a theoretical perspective, but, IIRC, they are not preferred numerically.
[a,b,c,d] = tf2ss(num,den);a,b,c
[T,a] = balance(a);
a
Apply the transformation to the b- and c-matrix
b = T\b
c = c*T
Show that the transfer function is unaffected (as must be the case with a similarity transformation)
[bb,aa] = ss2tf(a,b,c,0)
The CST returns the same result.
sys = ss(tf(num,den))
num = [0 3 2];
den = [1 4 4];
G = tf(num, den);
S = ss(G)
S.A
S.B
S.C
S.D
[A, B, C, D] = tf2ss(num, den)
At the moment I do not kow why the values do not match.
1 commentaire
Jan
le 19 Fév 2026
I guess ss(tf()) prescales the system and tf2ss(tf()) does not
Catégories
En savoir plus sur Digital Filter Analysis dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!