1
$\begingroup$

How to apply single pole filter to simple signal

fs = 500;
ts = 1/fs;
t = 0:ts:1-ts;
fc = 50;
S = cos(2*pi*fc*t);  
$\endgroup$
1
$\begingroup$

Given the transfer function of a single pole filter (without a zero):
$$H(z)= \frac{Y(z)}{X(z)} = \frac{1}{1-pz^{-1}}$$ Using the inverse z transform leads to the following equation: $$y[n] = x[n] + p y[n-1]$$

Your single pole filter can be implemented using a for-loop.

fs = 500; 
fc = 50; 
K = fs;  % 1 second of data
k = 0:(K-1);
x = cos(2*pi*fc/fs*k);

y = zeros(K,1);

p = 0.5;
y(1) = 0;  % Choose some initialization for y(1)
for n = 2:K
    y(n) = x(n) + p*y(n-1);
end

Another 'simple' test signal that can be used to visualize the behaviour of your filter is a random signal.

x = randn(K,1);

The spectrum of the filtered random signal shows the frequency characteristics of the filter.

$\endgroup$
1
$\begingroup$

If your pole is at $z=p$ (real or complex), this will do:

Y = filter( [1], [1, -p], S );

Free bonus: if you also want a zero at $z = c$:

Y = filter( [1, -c], [1, -p], S);

This last expression corresponds to the filter:

$$H(z) = \frac{1 - c z^{-1}}{1 - p z^{-1}}$$

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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