# Applying Discrete Filters

I have an exercise in DSP. I learnt about discrete filter but I don't know how to apply it to produce an output from an input signal. Please guide me to do this:

Assume fundamental sample time is 1 and Step time is 1, the result of output at time 5 is? • This looks like homework. People on this website will not do your homework for you, but they may give you hints if you show what you've tried and where you're stuck. – Phonon Jun 20 '14 at 0:58

Assuming that you have knowledge of DSP you claim, it is a very simple task.

First of all convert the difference block into proper filter representation (negative powers of $z$ reflect delay of samples), simply divide it by $z$:

$$\dfrac{z-1}{z}=\dfrac{\frac{z}{z}-\frac{1}{z}}{\frac{z}{z}}=\boxed{\dfrac{1-z^{-1}}{1}}$$

Now we have two filter blocks connected one after another, thus the transfer functions have to be multiplied to obtain general transfer function $H(z)$:

$$H(z)=\dfrac{Y(z)}{X(z)}=\dfrac{1-z^{-1}}{1} \cdot \dfrac{1}{1+z^{-2}}=\boxed{\dfrac{1-z^{-1}}{1+z^{-2}}}$$

Having the transfer function of our IIR filter, we can convert back to difference equation, let's multiply both sides of the above equation and use the time-shifting property of the Z-transform:

$$Y(z)\left(1+z^{-2}\right)=X(z)\left( 1-z^{-1}\right)$$ $$Y(z)+Y(z)z^{-2}=X(z)-X(z)z^{-1}$$ $$y[n]+y[n-2]=x[n]-x[n-1]$$

Thus our difference equation is:

$$\boxed{y[n]=x[n]-x[n-1]-y[n-2]}$$

We can now calculate signal samples of our system, input signal is the unit step.

Simulink note: As far as I remember Simulink by default is using unit step that is one for $n=1$:

$$u[n]= \begin{cases} 0 & n \le 0 \\ 1 & n > 0 \end{cases}$$

Most of people, including me prefer definition when $u[n]$ has non-zero sample at $n=0$. Obviously you can very easily change it with the initial value, but let me stick to the default behaviour, because you didn't provided enough informations about your simulation to make it 100% repeatable. Calculation of samples is straightforward while having difference equation, but let's do it for completion sake. Here it comes:

\begin{align} y=&0-0-0=\color{blue}{0} \\ y=&1-0-0=\color{red}{1} \\ y=&1-1-\color{blue}{0}=\color{cyan}{0} \\ y=&1-1-\color{red}{1}=\color{magenta}{-1} \\ y=&1-1-\color{cyan}{0}=0 \\ y=&1-1-(\color{magenta}{-1})=\boxed{1} \\ \end{align}