Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

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

share|improve this question

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.

1  
This looks like an exponential moving average‌​. –  Chris Taylor Jun 7 '12 at 13:25
3  
Also, this might be more appropriate for our DSP site. –  Chris Taylor Jun 7 '12 at 13:33

1 Answer 1

up vote 2 down vote accepted

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?

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

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