# Weird results when using MATLAB's $\tt butter$ function?

I'm trying to learn some of the basic MATLAB filter design functions and have been experimenting with the butter function. This function calculates the transfer function coefficients of a Butterworth filter given a desired filter order and normalized cutoff frequency.

I have previous experiences with designing prototype filters and then modifying them, however, I'm having a difficult time understanding MATLAB's definition of normalized frequency.

I'm used to designing Butterworth filters with a normalized frequency of $1 \textrm{ rad/s}$, yet MATLAB insists that the normalized frequency has something to do with a sample rate? I assumed the butter function was used for designing analog filters?

Furthermore, when I plot the frequency response of the function, the cutoff frequency I specify (Wn parameter) never seems to correspond to the $-3\textrm{ dB}$ mark in the plots.

Any thoughts on these?

• Regarding your last question, make sure you read the documentation carefully about how the Wn parameter is defined. Note that a Wn value of 1.0 corresponds to half the input sample rate. There is often a factor of 2 error here for first-time users of MATLAB's filter design functions. – Jason R Aug 5 '16 at 14:24

## 1 Answer

The answer to your question can mainly be found in the Matlab documentation. The butter function can design filters either in the analog domain as well as in the discrete domain. In order to make an analog filter, you can do so by giving the string 's' as a third parameters. The transfer function can be defined by the zeros/poles/gain or by numerator/denominator coeefficients. The two available syntaxes are

• [z,p,k] = butter(n,Wn,'s')
• [b,a] = butter(n,Wn,'s')

When designing a filter in the discrete domain, the normalized frequency is a ratio of the cutoff frequency over the biggest frequency that you can represent according to Nyquist theorem. For instance : if you have a sample time of 1ms, hence a sampling frequency of 1Khz, the biggest frequency you can represent is 500Hz. Designing a filter with a normalized frequency of 0.5 will put the cutoff frequency at 250Hz, since 250/500 = 0.5

In your question, you specify that the cutoff frequency didn't seems to match the -3dB point. Can you give us more detail about your issue. Maybe show us the work you have done until now ?