# Digital implementation of first order analog filter using bilinear transformation

I'm trying to create a digital filter from a first order analog filter with transfer function $$H(s)=\frac{1}{1+\tau s}$$ with time constant $\tau=.1\text{s}$, and sampling rate $f_s=1000\text{Hz}$.

Applying the bilinear transform in Matlab however appears to yield a filter with the a different 3dB point than expected. I expect the 3dB point to be at $\frac{1}{\tau}=10\text{Hz}$, but it appears to be around $1.6\text{Hz}$. Any idea what I could be doing incorrectly?

Matlab code:

fs = 1000;
tau = .1;

num = 1;
den = [tau, 1];
[numd,dend]=bilinear(num,den,fs);

[h, f] = freqz(numd,dend,4096, fs);

figure(1); clf();
subplot(211); semilogx(f,20*log10(abs(h))); hold on
plot([.1, 1000], [-3 -3],'r');
grid on; ylim([-40,1]); ylabel('gain (db)'); xlim([.1, fs/2]);
subplot(212); semilogx(f, angle(h)*180/pi);
grid on; ylabel('phase(rad)'); xlim([.1, fs/2]); xlabel('frequency(Hz)');

• Double-checked your code, it looks correct, and I am indeed getting the same result. Have you tried it with higher order filters? If the filter you need is an actual one-pole filter, you can design it without using bilinear transform quite easily. Is that what you're going for? – Phonon Oct 28 '13 at 18:50
• I haven't tried higher order filters. I'm simulating a neuron synapse as a first order, continuous time filter, so I am looking for a one-pole filter with the specified time constant. Is there another method you would recommend? – fragapanagos Oct 28 '13 at 21:29

The expected 3dB frequency is wrong because of radian conversion. With $s=j\omega$, $$H(j\omega) = \frac{1}{1+\tau j\omega}$$ and $20\log_{10}|H(j\omega)|\approx-3$ when $\omega=\omega_{3dB}=\frac{1}{\tau}$. However $\omega=2\pi f$, so $$f_{3dB}=\frac{\omega_{3dB}}{2\pi}=\frac{1}{2\pi\tau}.$$ With $\tau=0.1\text{s}$, $\ f_{3dB}=1.59\text{Hz}$ as on the original plots.

• I think this is actually the right answer. You should accept it instead when the systems allows you. Thanks for posting it. – Phonon Oct 30 '13 at 1:25
• yes, I will update accepted answer when I'm allowed to. Board says I have to wait for 16 hours. – fragapanagos Oct 30 '13 at 1:26

I was able to play around with the frequency warping parameter to get a result close to what you're looking for. The parameter value didn't turn out to be what I expected it to be, but I got a decent shape out of it anyway:

[numd,dend]=bilinear(num,den,fs, 470);


• I can replicate your solution, thanks, but I am also confused as to why the warping parameter has such an effect at the specified 3dB frequency, which seems much lower than sampling frequency. – fragapanagos Oct 28 '13 at 21:42
• figured it out. It was a unit conversion error in the expected 3dB frequency. See my answer. – fragapanagos Oct 30 '13 at 1:24

Might I suggest a completely different approach for those who don't use Matlab.

It is quite simple to get 2nd order IIR filter coefficients from the 1st and/or 2nd order coefficients of H(s). This link shows the derivations for low pass, high pass, band pass, and notch IIR filters. The final results are quite simple.

http://www.iowahills.com/A4IIRBilinearTransform.html