# Finding the Impulse Response Function for a state space model

I have converted the following ARMA model:

$$y(t+3)-y(t+2)-y(t+1)+y(t)=u(t+1)+2u(t)$$

into the following state space model:

$$x(t+1)=\begin{pmatrix}0 & 0 & -1\\ 1 & 0 & 1 \\ 0 & 1 & 1\\ \end{pmatrix}x(t)+\begin{pmatrix}2\\1\\0\\\end{pmatrix}u(t)$$

$$y(t)=\begin{pmatrix}0 & 0 & 1\\\end{pmatrix}x(t)$$

Where the Impulse Response function $I(t)=c^T*A^{t-1}*b$.

Where $$c=\begin{pmatrix}0 & 0 & 1\\\end{pmatrix}$$

$$A=\begin{pmatrix}0 & 0 & -1\\ 1 & 0 & 1 \\ 0 & 1 & 1\\ \end{pmatrix}$$

$$b=\begin{pmatrix}2\\1\\0\\\end{pmatrix}$$

I have then used Matlab to plot the Impulse Response function for discrete time for $0\le t \le 20$ and I have this graph:

My Matlab code is this:

clear
A=[0 0 -1; 1 0 1; 0 1 1]; % define matrices
b=[2 ; 1; 0];
c=[0 ; 0 ; 1];

y(1)=0; % impulse response function
tt(1)=0;

for i=0:20
tt(i+1)=i;
y(i+1)=c'*A^(i-1)*b;
end

figure(1)
plot(tt,y)
title('(b) impulse response function')


Is this correct? I've seen other examples of Impulse Response functions and they seem to oscillate around the x-axis and mine obviously seems different.

• Rewriting this in terms of vectors and matrices should yield $$x(t)=\begin{pmatrix}y(t+2)\\ y(t+1)\\ y(t)\end{pmatrix}\qquad v(t)=\begin{pmatrix}u(t+1)\\ u(t)\end{pmatrix}$$ and the dynamics $$x(t+1)=Ax(t)+Bv(t)$$ with $$A=\begin{pmatrix}1&1&-1\\ 1&0&0\\ 0&1&0\end{pmatrix}\qquad B=\begin{pmatrix}2&1\\ 0&0\\ 0&0\end{pmatrix}$$ and finally $$\qquad y(t)=\begin{pmatrix}0&0&1\end{pmatrix}x(t)$$ This seems quite different from what you write in your question. Please explain. – Did Mar 19 '17 at 11:12
• @Did I have been taught that the general form of the ARMA Model is: $$y(t+n)+a_1y(t+n-1)+...+a_ny(t)=b_1u(t+n-1)+...+b_nu(t).$$ Then the definition I have of the State Space Model is: $$x(t+1)=Ax(t)+bu(t), y(t)=C^Tx(t).$$ Then to transform an ARMA Model to a State Space model you use this formula for $n=n$ (whereas my question has $n=3$): $$x(t+1)=\begin{pmatrix} 0 & 0 & \cdots & 0 &0& -a_n\\ 1 & 0 & \cdots & 0 & 0& -a_{n-1}\\ 0 & 1 & \cdots & 0 &0& -a_{n-2}\\ \vdots & \vdots & \ddots & \vdots & \vdots & \vdots\\ 0 & 0 &\cdots &1&0 & -a_2\\ 0 & 0 & \cdots & 0 & 1 & -a_1\\ \end{pmatrix}$$ – DavinaGoodman Mar 19 '17 at 14:00
• No, your matrices are wrong and of course $u(t)$ alone will not suffice to compute $x(t+1)$, one will need $u(t+1)$ and $u(t)$. Simply compute the products and you will see. – Did Mar 19 '17 at 14:02
• So then $x(t+1)$=(the above matrix)$*x(t)$+$$\begin{pmatrix} b_n\\ b_{n-1}\\ \vdots \\ b_2 \\ b_1 \\ \end{pmatrix}*u(t)$$ and $$y(t)=(0 0 0 .... 0 1)x(t).$$ Sorry I ran out of characters to finish the definition. Okay I will change the matrices, so the definition I have been given to transform the ARMA Model to a State Space Model is incorrect? – DavinaGoodman Mar 19 '17 at 14:20

First you need to derive a transfer function from your recurrence relation and the $z$-transform. The trick is to consider the farthest term from $t$, (here $t+3$) as the reference and then put $z^{-n}$ for each term where $n$ is the distance from that reference: $$y(t+3)-y(t+2)-y(t+1)+y(t)=u(t+1)+2u(t)\\ \implies Y(z)(1-z^{-1}-z^{-2}+z^{-3})=U(z)(z^{-2}+2z^{-3})$$ So the transfer function is $$G(z)=\frac{Y(z)}{U(z)}=\frac{z+2}{z^3-z^2-z+1}=\frac{z+2}{(z+1)(z-1)^2}$$ and you won't need to compute a state-space model for obtaining the impulse-response:
sys = tf([1,2], [1,-1,-1,1], 1); % sampling period = 1 sec

As a side-note, since the system has a double-pole at $z=1$, it would be unstable. You can also verify this by taking the inverse $z$-transform of the transfer function, which is the impulse response! $$g[n]=\mathcal Z^{-1}\{G(z)\}=\frac 14\left(6n-7+(-1)^{n-1}\right)u[n-1]$$