Ran
Ran

Reputation: 25

Transformation 2 input 2 output transfer function into state space model using MATLAB

I have 4 transfer function that are G11, G12, G21, and G22. And how do I convert this 4 transfer function into a state space model? The following are my codes, however, the results of state space model are different from the linearization using SIMULINK.

g_num11=[4];
g_den11=[1 4];
g11=tf({g_num11},{g_den11});

g_num12=[5.338e-76];
g_den12=[1 8.674 18.7];
g12=tf({g_num12},{g_den12});

g_num21=[-1.5268e-79];
g_den21=[1 15.02 72.02 111.7];
g21=tf({g_num21},{g_den21});

g_num22=[2.539];
g_den22=[1 11.02 29.67];
g22=tf({g_num22},{g_den22});

g_plant=tf({g_num11 g_num12; g_num21 g_num22}, {g_den11 g_den12; g_den21 g_den22})
sys=ss(g_plant,'min')
%Convert transfer function model  into state space model
[A,B,C,D]=ssdata(sys)

The results are shown below:
A =

   -4.0000   -0.0000   -0.0000
   -0.0000  -11.0200   -7.4175
    0.0000    4.0000   -0.0000


B =

   -2.0000    0.0000
    0.0000    1.0000
    0.0000   -0.0000


C =

   -2.0000    0.0000    0.0000
    0.0000   -0.0000    0.6348


D =

     0     0
     0     0

The results below are using Linear Analysis in the SIMULINK window to linearize.

A =

   -4.0000   -0.0000   -0.0000
   -0.0000   -4.67400  -0.6744
    0.0000    0.0000   -6.3480


B =

   -4.0000    0.0000
    0.0000    0.0000
    0.0000    3.7650


C =

    1.0000    0.0000    0.0000
    0.0000    1.0000    0.0000


D =

     0     0
     0     0

Thanks for your help =)

Upvotes: 0

Views: 5095

Answers (1)

Rasman
Rasman

Reputation: 5359

Converting to a SS model is always an ugly process, and depending on the method you can get different representation. So don't obsess over getting equal values of A B C and D.

Also, the states of SS that have been converted from TF often have no meaning other the storing information of the previous state.

To verify whether you have similar SS system, throw in an impulse response:

impulse (sys, sysSimulink)

From the documentation:

Recommended Working Representation

You can represent numeric system components using any model type. However, Numeric LTI model types are not equally well-suited for numerical computations. In general, it is recommended that you work with state-space (ss) or frequency response data (frd) models, for the following reasons:

The accuracy of computations using high-order transfer functions (tf or zpk models) is sometimes poor, particularly for MIMO or high-order systems. Conversions to a transfer function representation can incur a loss of accuracy.

When you convert tf or zpk models to state space using ss, the software automatically performs balancing and scaling operations. Balancing and scaling improves the numeric accuracy of computations involving the model. For more information about balancing and scaling state-space models, see Scaling State-Space Models.

Upvotes: 0

Related Questions