1
$\begingroup$

I have a difference equation for a Single Pole Infinite Impulse Response Filter, defined on a discrete time-series:

$y[n]-(1-\alpha)*y[n-1]=\alpha*x_n$

While the []s brackets refer to a position n within the series. I'm looking for a visual way to represent this in order to get how this equation behaves. I have tried wolfram-alpha, MalLab... Is anyone me a pointer how I can make MatLab (e.g.) show me the plot for this function? Use-case is a DC offset filter, that uses this SPIIR filter with $\alpha=0,0004$. So it's mostly DSP related.

Best, Marius

  • 3
    Also, this might be more appropriate for our [DSP](http://dsp.stackexchange.com/) site.2012-06-07

1 Answers 1

2

Let's do a quick rewrite into more 'mathematical' notation:

$y_n = \alpha x_n + (1-\alpha) y_{n-1}$

By repeated substitution you can see that this is equal to:

$ \begin{align} y_n & = \alpha \left( x_n + (1-\alpha) x_{n-1} + (1-\alpha)^2 x_{n-2} + \cdots \right) \\ & = \alpha \sum_{k=0}^\infty (1-\alpha)^k x_{n-k} \end{align}$

So $y$ is an infinite sum of past values of $x$ (which is why it's called an infinite impulse response filter). One way to visualize this is to look at the weights

$w_k = \alpha(1-\alpha)^k$

as a function of $k$, which you can achieve in Matlab by

alpha = 0.2; k = 0:20; w = alpha .* (1-alpha).^k; bar(k,w) 

another way is to generate some data x and calculate y from it, and compare the two:

x = randn(30,1); y = zeros(30,1);  y(1) = x(1);  for k = 2:30   y(k) = alpha * x(k) + (1-alpha) * y(k-1); end  plot(1:30, [x y]) legend({'x','y'}) 

Is this what you meant by 'visualize' the equation?

  • 0
    That's because Matlab has an annoying quirk of growing arrays horizontally instead of vertically. It's fixed now.2012-06-07