next up previous
Next: The State-Space Method of Up: Solution of difference equations Previous: Complete direct solution of

Complete solution of a DE using the MATLAB function `filter'

The DE is of the form :

displaymath431

where tex2html_wrap_inline347 must not equal zero.

To use MATLAB filter we set up the row vectors :

displaymath432

and the input row vector tex2html_wrap_inline455

If we now call filter with : y=filter(b,a,x) the output y is computed for the times at which the inputs x are specified but zero initial conditions are assumed.

To specify initial conditions an initial condition vector v0 say must be determined from the initial conditions y(-1),y(-2),...,y(-N) according to the following rule :

displaymath433

displaymath434

displaymath435

displaymath436

For filter v0 needs to be a column vector :

displaymath437

Then call filter with y=filter(b,a,x,v0) .

Example :
Find the output of the system described by the DE :

displaymath438

for the case where the input x(n)=u(n) and the initial conditions are y(-1)=-1 y(-2)=-2 and y(-3)=-3 .

Calculate the IC vector :

displaymath439

displaymath440

displaymath441

MATLAB script :
n=0:1:40;
a=[1 -0.25 -0.125 0.5];
b=[3];
v0=[1.0;0.875;0.5];
x=[ones(size(n))];
y=filter(b,a,x,v0);
plot(n,y,'o');



Keith Jones
Mon Oct 26 11:49:50 EST 1998