# Analog butterworth to digital - bilinear transform

In my previous question I've designed analog butterworth filter (poles own calculated). But now I would like to transform it to digital domain. I'm using bilinear transformation but not all is clear for me. Please look at my script below:

clc, clear all, close all;

%ANALOG BUTTERWORTH FILTER DESING
%https://engineering.purdue.edu/~ee538/AnalogFilterDesigns.pdf

%Butterworth LP with -3dB at fc and N order and G gain

wc = 1000;   %cut off frequency
N = 2;      %filter order
G = 1;      %filter gain

%analog filter design with prewarped frequency
%poles and zeros

%frequency normalizing and prewarping
wc = 2*tan(wc/2);

%poles searching
for k = 0:N-1
sk(k+1) = wc*exp(j*(pi/2))*exp(j*(2*k+1)*(pi/(2*N)));
end

[NUM,DEN] = zp2tf([],sk,G);
b0 = DEN(end)*G      %gain normalization

Hs = tf(b0,DEN)

figure();
freqs(b0,DEN)
title('lowpass filter with pre-warped frequency visualization')
figure();
plot(sk./10^2, 'x')
xlim([-10,10]);
title('Poles placement in s-plane')

%continuous to digital conversion
[NUMD,DEND] = bilinear(b0,DEN,1);

fvtool(NUMD,DEND)


Results looks like below:

I'm sure that is not what I want, because I have nowhere applied frequency sampling that is interesting me. I'm not also sure if I've done prewarping well.

EDIT: frequency response for ws = 2000 in bilinear transformation:

• uhm, what's your sample rate? is it $f_\text{s}=1$ and you have $\omega_c = 1000$? me thinks your tangent function has wrapped several times over. better settle that issue. May 15, 2016 at 17:25
• @robertbristow-johnson Hmm, you're right. But I thought it is normalized frequency. When I apply for example ws = 2000 (2*wc) frequency response looks totally senseless. I've attached image in my post (edited) May 15, 2016 at 18:35
• if you're not dividing by $f_\text{s}$ somewhere, it must be specified as normalized. and i am certain that $\omega_c=1000$ is not normalized. so you have a problem here. (i am holding back telling you specifically what you need to do.) May 16, 2016 at 1:56
• @robertbristow-johnson Ok I assume I have to normalize cutoff frequency so I've divided wc by ws/2 and apply this ws to bilinear transform. But it is still senseless. May 16, 2016 at 9:31
• i think you should divide $\omega_c$ by $f_\text{s}$. take a look at the Audio EQ Cookbook for how to transform an analog prototype (with "normalized frequency" w.r.t. the resonant frequency) to a digital filter (with resonant frequency below Nyquist) using the bilinear transform. the steps are at the bottom. May 16, 2016 at 18:06

## 1 Answer

look at MATLAB bilinear(). you are specifying fs=1 in your call to it.

if you're gonna do any digital filtering, sometime, somewhere you need to commit to a sampling frequency and you haven't yet.