Thursday, 14 April 2011

Converting a continuous statespace model to ARMA model

In many situation we need to convert a continuous statespace model in to a linear difference equation model or ARMA/ARMAX discreet time model. This post describes this conversion with some simple examples. 

Example 1: Conversion of First Order Differential Equation to Linear Difference Equation

we will start with a simple example here.  
Let us take a simple first order differential equation: 

--  =  - x

This state space model is with A=-1 and B=0,
we want to discreetize it with T=1s and get a linear differential equation model;

First calculate A1 and B1 as following:
1. Using the properties of z=e^-(st), we get that
 or in other words, we can say that

  A1=Linv((sI-A)^-1)  with t=T; 
  A1=Linv(1/(s+1))     =exp(-t) at (t=T)   =e^-1
then similarly

  B1= A^-1 (A1-I)B;= -1(e-1)*0 = 0

so the new model is
x[n+1]=1/e x[n]   
So the final model in linear differential equation is
           x[n+1]-1/e x[n]=0
is the ARM model you wanted

Note :
       exp used is matrix exponential
       exp(A)= I+A+A^2/2!+A^3/3!+... = Linv{(sI-A)^-1}

Example 2: Considering the Inputs
Now consider this

---- =-x+u(t);
So we have
 or in other words, we can say that
  Linv((sI-A)^-1)  with t=T; 
 A1=Linv(1/(s+1))     =exp(-t) at (t=T)   = e^-1

  B1= inv(A)(A1-I)B;=-1(1/e-1)*1=1-1/e;
so the new model is
x[n+1]=A1 x[n]+B1u[n]
       x[n+1]=1/e x[n]+(1-1/e)u[n];
        x[n+1]-1/e x[n]=(1-1/e)u[n];

x[n+1]-1/e x[n]=(1-1/e)u[n];

Another Method Using Transfer Functions
Let us learn one more method for this.
first calculate the transfer function of this state space model
which is

 G(s)= 1/(s+1);

now discreetize it by using

z=exp(sT)=exp(s) as T=1;

This pretty tricky so we will take the help of MATLAB here to calculate it.

On MATLAB, write the following :
 %make the transfer function using tf
 g=tf(1,[1 1]);
 %convert it to discreet

you will get

Now it is very easy to convert it to time domain
z X(z)-X(z)/e=(1-1/e)U(z);
The final model is
x[n+1]-1/e x[n]= (1-1/e)u[n]
which is same as earlier one.

No comments:

Post a Comment