# How to find the output signal of a filter using state space matrices?

I have a filter. It has two poles and two zeros.

I found the state space equations and the matrices A, B, C, and D

Now. I have 9 samples that I need to process with my filter. How do I use A,B,C,D matrices to process the samples?

$$\begin{array} &y[n] &= \mathbf{C}x[n] + \mathbf{D}u[n]\\ x[n+1] &=\mathbf{A}x[n] + \mathbf{B}u[n] \\ \end{array}$$

Where $u[n]$ is the input signal value, $x[n]$ is state vector value at a given point in time, and $y[n]$ is obviously the output.

What you need to do is to:

• Initialize the initial state $x$ to some arbitrary value (usually vector of zeros).
• Run the calculation by consequently calculating values of $y[n]$ and $x[n+1]$ to be used in the next step.

Speaking Matlab'ish (not tested, cause I am in travel, but given all informations its extremely easy to figure out what is going on):

b = [0 2 3];
a = [1 0.4 1];
[A,B,C,D] = tf2ss(b,a);

x_0 = zeros(size(A,1), 1); % Initial state
N = 9;
u = randn(1, N); % Some input signal
y = zeros(N, 1); % Output signal

x = u_0;
for n=1:N-1
y(n) = C*x + D*u(n); % System output
x = A*x + B*u(n);    % Transition
end


i dont understand exactly what is your requirment.But you can find Tranfer funtion (and hence freq responce by putting 's=jw')of the filter.Here is the method,

dx/dt=Ax+Bu; (x is a state variable,y is output, and u is input) Y =Cx+Du

applying Laplace Tranform on both sides

sX(s)=AX(s)+BU(s); Y(s) =CX(s)+DU(s);

sX(s)-AX(s)=BU(s); X(s){SI-A}=BU(s); (I is unit matrix)

X(s)=([SI-A]^-1)BU(s);

X(s) = V(s)BU(s) V(s)=[SI-A]^-1

Y(s)=CV(s)BU(s)+DU(s) ;

Y(s)/X(s) =CV(s)B+D;

this is Tranfer Function in 's' domain.

• can you please explain why it is not helpful?, are you confused with notations? – spectre Feb 17 '15 at 18:23