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


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


closed as off topic by Qiaochu Yuan Jun 10 '12 at 11:05

Questions on Mathematics Stack Exchange are expected to relate to math within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here. If this question can be reworded to fit the rules in the help center, please edit the question.


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;

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);

plot(1:30, [x y])

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

  • $\begingroup$ Yes, that's it. Thanks! - However the last plot command seems to be wrong: "Error using horzcat CAT arguments dimensions are not consistent." $\endgroup$ – wishi Jun 7 '12 at 13:48
  • $\begingroup$ That's because Matlab has an annoying quirk of growing arrays horizontally instead of vertically. It's fixed now. $\endgroup$ – Chris Taylor Jun 7 '12 at 13:53

Not the answer you're looking for? Browse other questions tagged or ask your own question.