# Sampling frequency in bilinear transform when designing butterworth filter

I'm trying to design digital Butterworth filter from scratch. First I use butterap to design an analog prototype to get zeros, poles and gain

[za, pa, ka] = buttap(n);


Here I set n = 5 for example and then convert it to transfer function to check its frequency response

[b, a] = zp2tf(za, pa, ka);
freqs(b, a);


From the figure above I know it's a lowpass filter with cutoff frequency $$\Omega_c=1$$.

Now I want to convert this analog filter to a half-band lowpass digital filter using bilinear transform, according to the documentation of MATLAB's bilinear.

% Strip any zeros at infinity
za = za(isfinite(za));
% Do bilinear transformation
pd = (2 * fs + pa) ./ (2 * fs - pa);
zd = (2 * fs + za) ./ (2 * fs - za);
kd = real(ka * prod(2 * fs - za) ./ prod(2 * fs - pa));
% Add extra zeros at -1 so the resulting system has equivalent numerator and denominator order.
zd = [zd; -ones(length(pd) - length(zd), 1)];


Then convert it to transfer function and look at the frequency response

[b, a] = zp2tf(zd, pd, kd);
figure; freqz(b, a);


My question is about the sampling frequency $$f_s$$. I want a half-band lowpass filter meaning that $$\omega_c = 0.5\pi$$. From the relationship between digital frequency and analog frequency $$\omega = \Omega T$$ I can derive that $$T = 0.5\pi\ \text{s}$$ and $$f_s = 1/T = 2/\pi\ \text{Hz}$$. The following figure shows the frequency response when I set fs = 2/pi

Apparently it doesn't have a -3 dB attenuation at $$\omega = 0.5\pi$$. Only when I set fs = 0.5 can I get the desired result:

Anyone can help me to find where am I wrong? Thank you in advance.

Bilinear transform has a nonlinear frequency mapping $$\varOmega = \frac{2}{T}\tan{\frac{\omega}{2}}$$ Substituting $$\varOmega = 1$$ and $$\omega = 0.5\pi$$ into it and you can derive that $$T = 2$$ and thus $$f_s = 0.5$$