# I do not understand the frequency calculation used in the construction of this IIR digital Butterworth Low pass filter using MATLAB

The question is to design a Low Pass Butterworth IIR Digital filter. The following code below has the specifications with $$A_p$$ being the passband attenuation, $$A_s$$ the stop band attenuation, $$f_{pb}$$ is the passband frequency and $$f_{sb}$$ is the stop band frequency. $$f_s$$ is the sampling frequency all in Hz.

I do not understand what formulas are used to calculate the cutoff frequency. I normalised the frequencies using:

$$\omega_{pb} = \frac{f_{pb}}{f_s/2}$$ $$\omega_{sb} = \frac{f_{sb}}{f_s/2}$$

I could successfully calculate order using:

$$N = \frac{\log_{10}\left(\frac{10^{0.1\cdot A_p}-1}{10^{0.1\cdot As}-1}\right)}{2\log_{10}(f_p/f_s)}$$

but when I calculated cutoff frequency using :

$$\omega_c = \frac{\omega_{pb}}{\left(10^{0.1\cdot Ap}-1\right)^{1/(2N)}}$$

I am getting the result as $$\omega_c = 0.21916$$

**MATLAB CODE:**
Ap=1.25;    As=15;  fpb=200;    fsb=300;    fs=2000;

[N,fc]=buttord(200/(fs/2),300/(fs/2),Ap,As)

[b,a]=butter(N ,fc) % fc = 0.2329, N = 6


So how are the frequency calculations done ?

EDIT: FOUND THE SOLUTION

I looked into buttord.m in MATLAB and found out that it converts the normalised frequencies given to it by pre-warping those frequencies and converts it into analog domain. It finds the normalised Low pass filter design with the required cut off. So all the intermediate calculation is done in the analog domain frequency and for the resultant cutoff it shows, it again warps the frequency in order to obtain the digital frequency.

Also the bi-linear transform is used to obtain the transfer function of the digital filter.

• I have converted you mathematical expressions into MathJax (edit may be pending). Please check I have done so correctly and consider using MathJax in the future. Feb 13 at 11:13
• I'm not sure how we can help you, other than by doing what you yourself could also do: check the code in buttord.m. I suppose it has to do with frequency warping. Feb 13 at 11:24
• @MattL. This tip was really helpful, I found out the internal working of the code. Feb 13 at 14:21
• @Circuit_Breaker0.7, can you share what you have found as an answer to your question? Feb 15 at 2:01
• I have made the edit @GrapefruitIsAwesome Feb 15 at 11:50

Pre-warping: $$\Omega_{pb} = {tan(w.pi/2)}{}$$ where w is the normalised frequency.
Similarly, while displaying the cutoff frequency, MATLAB warps the frequency again to show it in the original digital domain as: $$\omega_{c} = 2.{arctan(\Omega_c)}/pi$$