0
$\begingroup$

Let's say I have used MATLAB's butter function to generate a 3rd order, low-pass, Buttersworth, digital filter. I have a sample rate of $2000\textrm{ samples/second}$, and I want the cutoff frequency to correspond to an analog frequency of $700\textrm{ Hz}$. Because MATLAB defines its normalized frequencies as percentages of the Nyquist frequency, the $700\textrm{ Hz}$ would turn into $700/1000 = 0.7$. I feed these parameters into the butter function and outcomes my filter coefficients.

I then use the freqz function on these coefficients to obtain the [h, w] vectors. h corresponds to the filter output at a specific frequency, and w is the angular frequency.

I'm having a difficult time understanding the units of the angular frequency. I would typically think of $\omega$ of having units of $\rm rad/s$, but i don't believe this is correct due to us having normalized the frequency earlier.

  • Would anyone mind explaining to me the units of w outputs by freqz?
  • And specifically how I would be able to scale that back to an analog frequency in $\textrm{Hz}$?
$\endgroup$
2
$\begingroup$

After a little hard thought, I believe I stumbled across the answer. In order to know how to convert, you really need to pay attention to units.

When you use the 'butter' function, it is necessary that you normalize the frequency. By normalizing the frequency, you are essentially removing the time dependency and are only focused on relative values. Commonly in DSP, this frequency is achieved by dividing the analog frequencies by the sampling rate. In this, the units of the normalized frequency are cycles/sample. This was achieved by dividing the analog frequency in hz (cycles/second) by the sample rate (samples/second). Dividing these yields the units of cycles/sample. Notice now that there is no units of seconds, we have thus removed the time dependency.

However, MATLAB is different in the sense that it likes to normalize the analog frequencies in terms of the Nyquist rate as opposed to the sample rate. The Nyquist rate is 1/2 the sample rate. The reason for this is due sampling theorem which states that the sampling rate must be twice that of the true frequency in order to capture the true frequency. For analog frequencies greater than 1/2 the sampling rate, they will be aliased onto frequencies less than 1/2 the sampling rate. Again, just refer to the sampling theorem.

So now, using MATLAB's convention, the real units of the normalized frequency is (1/2 cycles)/sample. Fine and dandy.

After using the 'butter' function to obtain the filter coefficients, we feed them into the 'freqz' function which will create an h and w vector. h and w are the frequency response and angular frequencies respectively. Assuming you know about frequency responses/bode plots, the h vector should make sense.

However, the real question is regarding the w vector. MATLAB states that the w vector is the angular frequency vector. But what are the units of this angular frequency? Well typically when you think of angular frequency in terms of radians, you think of radians/second. However, since we're working with normalized frequencies with removed time dependencies, the units of normalized angular frequencies is radians/sample. If you look at the range of the w vector, you will notice that is goes from 0 radians/ample to pi radians/sample. This make sense due to the fact that pi radians/sample is equivalent to (1/2 cycles)/sample which covers the entire normalized frequency range up until the normalized Nyquist frequency.

So we're now at the point where we have our filter response magnitude 'h', but it's been evaluated at the weird units of radians/sample. We want to get back to our analog frequency equivalent which has units of Hz (Hz = cycles/second).

It's now simply a game of unit analysis of converting radians/sample -> cycles/second.

That's achieved by doing the following operation to the w vector:

w*Fs/(2*pi) -> units of Hz.

TL;DR freqz computes the digital filter response in terms of radians/sample. We want to convert this to Hz (which is cycle/second). To do so, multiply by Fs/(2*pi).

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.