Hello everyone! In this post I want to share with you a simple Matlab program to convert state space model to transfer function.

In modern control systems, state space models are in common use because of its advantage over classical control system involving transfer function. One of the most common advantage is transfer function can be used only for zero initial condition, whereas state space models can be used for systems involving both zero and non-zero initial conditions.

Now let us come to the main topic, i.e. converting state space model to transfer function in Matlab. In Matlab, we can perform this task in 2 ways:

1. Using the direct command ‘SS2TF()
2. Without using ‘SS2TF()’ command

Let me brief about each of the 2 ways:

I.    Using Direct command
In this way, Just enter the matrix A,B,C and D from the state space model of

X'=Ax+Bu
Y=Cx+Du

And then use the syntax:

[num,den]= ss2tf(A,B,C,D)

This will return the numerator and denominator of the transfer function. The Matlab codes are shown below:

`%program to convert state space model to transfer function%using SS2TF() function%Author:    Amit Biswal @ Speaking Technology%URL:       http://amitbiswal.blogspot.comclcclear allA=[0 1 0;0 0 1; -1,-2,-4]B=[0;0;10]C=[1 0 0]D=[num,den]=ss2tf(A,B,C,D)T=tf(num,den)`

II.    Without using direct command

In this method, we will use our theoretical knowledge and apply the formula for transforming state space model to transfer function, i.e

T(s)=C(sI-A)-1B+D

The Matlab codes for the same are shown below:

`%program to convert state space model to transfer function%without using SS2TF() function%Author:    Amit Biswal @ Speaking Technology%URL:       http://amitbiswal.blogspot.comclcclear allA=[0 1 0;0 0 1; -1,-2,-4]B=[0;0;10]C=[1 0 0]D=s=tf([1 0],1);I=eye(3);T=(C*((inv((s*I)-A))*B))+D`