DSPRelated.com
Forums

Group delay in Matlab

Started by gab September 18, 2006
Dear all

I not very familiar with filter design in Matlab and I am probably missing
something when it comes to "group delay". My problem comes as follows.

From what I have understood, if I have a filter such that its group delay
response (plotted with grpdelay[b,a] in matlab with a,b the filter
coefficients) provides 17 as the group delay (in samples) at f=0.14
(normalized frequency so f=0.14*fs/2=0.14*500=70Hz, sampling frequency
being 1000 Hz) then passing a sinusoid whose frequency is 70Hz through the
filter I should get at the output the same sinusoid (assuming gain is one)
delayed by 17 samples. 

But it not what I obtain! I have made a lot of tests with different input
frequency in the range [0...fs/2] and I always get a smaller delay than
what I should expect from the group delay response of the filter.

Does anyone have an explaination to provide me?
It sounds to me really basic and I am really wasting my time with it!!!

Thanks for your help 
Gabriel






gab said the following on 18/09/2006 17:27:
> Dear all > > I not very familiar with filter design in Matlab and I am probably missing > something when it comes to "group delay". My problem comes as follows. > > From what I have understood, if I have a filter such that its group delay > response (plotted with grpdelay[b,a] in matlab with a,b the filter > coefficients) provides 17 as the group delay (in samples) at f=0.14 > (normalized frequency so f=0.14*fs/2=0.14*500=70Hz, sampling frequency > being 1000 Hz) then passing a sinusoid whose frequency is 70Hz through the > filter I should get at the output the same sinusoid (assuming gain is one) > delayed by 17 samples. > > But it not what I obtain! I have made a lot of tests with different input > frequency in the range [0...fs/2] and I always get a smaller delay than > what I should expect from the group delay response of the filter. > > Does anyone have an explaination to provide me? > It sounds to me really basic and I am really wasting my time with it!!!
I think you are confusing group delay and phase delay. Phase delay is defined as: t = phi/omega whereas group delay is: t = d phi / d omega [i.e. the derivative]. Phase delay is the absolute delay at a given frequency, and I think this is what you were expecting from your simulation. -- Oli
gab wrote:

> Dear all > > I not very familiar with filter design in Matlab and I am probably missing > something when it comes to "group delay". My problem comes as follows. > > From what I have understood, if I have a filter such that its group delay > response (plotted with grpdelay[b,a] in matlab with a,b the filter > coefficients) provides 17 as the group delay (in samples) at f=0.14 > (normalized frequency so f=0.14*fs/2=0.14*500=70Hz, sampling frequency > being 1000 Hz) then passing a sinusoid whose frequency is 70Hz through the > filter I should get at the output the same sinusoid (assuming gain is one) > delayed by 17 samples. > > But it not what I obtain! I have made a lot of tests with different input > frequency in the range [0...fs/2] and I always get a smaller delay than > what I should expect from the group delay response of the filter. >
Of course you have taken into account that 17 samples is ~2.7 samples over the wavelength? Thus, it might seem that the delay is smaller (i.e., 2.7).
> Does anyone have an explaination to provide me? > It sounds to me really basic and I am really wasting my time with it!!!
If you truly are interested in how much a sine wave is delayed then you should use the phase delay as Oli has advised you. However, if you're interested in the delay of bandlimited signal around f=0.14, then group delay is the weapon of choice (assuming that the phase is sufficiently linear around f=0.14) Check this link for an introduction to subject: http://ccrma.stanford.edu/~jos/filters/Phase_Response_Applications.html
> > Thanks for your help > Gabriel
-- Jani Huhtanen
What's your application here?  What type of filter is this?

* Group name: RealTime_Signal_and_Control
* Group home page:
http://groups.google.com/group/realtime_signal_and_control
* Group email address realtime_signal_and_control@googlegroups.com

Jani Huhtanen wrote:
> gab wrote: > > > Dear all > > > > I not very familiar with filter design in Matlab and I am probably missing > > something when it comes to "group delay". My problem comes as follows. > > > > From what I have understood, if I have a filter such that its group delay > > response (plotted with grpdelay[b,a] in matlab with a,b the filter > > coefficients) provides 17 as the group delay (in samples) at f=0.14 > > (normalized frequency so f=0.14*fs/2=0.14*500=70Hz, sampling frequency > > being 1000 Hz) then passing a sinusoid whose frequency is 70Hz through the > > filter I should get at the output the same sinusoid (assuming gain is one) > > delayed by 17 samples. > > > > But it not what I obtain! I have made a lot of tests with different input > > frequency in the range [0...fs/2] and I always get a smaller delay than > > what I should expect from the group delay response of the filter. > > > > Of course you have taken into account that 17 samples is ~2.7 samples over > the wavelength? Thus, it might seem that the delay is smaller (i.e., 2.7). > > > Does anyone have an explaination to provide me? > > It sounds to me really basic and I am really wasting my time with it!!! > > If you truly are interested in how much a sine wave is delayed then you > should use the phase delay as Oli has advised you. However, if you're > interested in the delay of bandlimited signal around f=0.14, then group > delay is the weapon of choice (assuming that the phase is sufficiently > linear around f=0.14) > > Check this link for an introduction to subject: > http://ccrma.stanford.edu/~jos/filters/Phase_Response_Applications.html > > > > > Thanks for your help > > Gabriel > > -- > Jani Huhtanen
What's your application here?  What type of filter is this?

* Group name: RealTime_Signal_and_Control
* Group home page:
http://groups.google.com/group/realtime_signal_and_control
* Group email address realtime_signal_and_control@googlegroups.com

Jani Huhtanen wrote:
> gab wrote: > > > Dear all > > > > I not very familiar with filter design in Matlab and I am probably missing > > something when it comes to "group delay". My problem comes as follows. > > > > From what I have understood, if I have a filter such that its group delay > > response (plotted with grpdelay[b,a] in matlab with a,b the filter > > coefficients) provides 17 as the group delay (in samples) at f=0.14 > > (normalized frequency so f=0.14*fs/2=0.14*500=70Hz, sampling frequency > > being 1000 Hz) then passing a sinusoid whose frequency is 70Hz through the > > filter I should get at the output the same sinusoid (assuming gain is one) > > delayed by 17 samples. > > > > But it not what I obtain! I have made a lot of tests with different input > > frequency in the range [0...fs/2] and I always get a smaller delay than > > what I should expect from the group delay response of the filter. > > > > Of course you have taken into account that 17 samples is ~2.7 samples over > the wavelength? Thus, it might seem that the delay is smaller (i.e., 2.7). > > > Does anyone have an explaination to provide me? > > It sounds to me really basic and I am really wasting my time with it!!! > > If you truly are interested in how much a sine wave is delayed then you > should use the phase delay as Oli has advised you. However, if you're > interested in the delay of bandlimited signal around f=0.14, then group > delay is the weapon of choice (assuming that the phase is sufficiently > linear around f=0.14) > > Check this link for an introduction to subject: > http://ccrma.stanford.edu/~jos/filters/Phase_Response_Applications.html > > > > > Thanks for your help > > Gabriel > > -- > Jani Huhtanen
gab wrote:
> Dear all > > I not very familiar with filter design in Matlab and I am probably missing > something when it comes to "group delay". My problem comes as follows. > > From what I have understood, if I have a filter such that its group delay > response (plotted with grpdelay[b,a] in matlab with a,b the filter > coefficients) provides 17 as the group delay (in samples) at f=0.14 > (normalized frequency so f=0.14*fs/2=0.14*500=70Hz, sampling frequency > being 1000 Hz) then passing a sinusoid whose frequency is 70Hz through the > filter I should get at the output the same sinusoid (assuming gain is one) > delayed by 17 samples. > > But it not what I obtain! I have made a lot of tests with different input > frequency in the range [0...fs/2] and I always get a smaller delay than > what I should expect from the group delay response of the filter. > > Does anyone have an explaination to provide me? > It sounds to me really basic and I am really wasting my time with it!!!
As others have already stated, there may be issues with the sinusoidal period vs the delay, or confusion with phase velocity. Yet another potential issue is whether the group velocity makes sense for monochromatic signals. Group velocity is defined as vg = dw/dk where k is wavenumber and w is the angular frequency. Since there are differentials involved, the signal necessarily needs to be broad-band, which a single sinusoidal is not. Maybe the group velocity is easier to come to terms with if you apply a broad-band pulse to the system. As for wasting your time: These issues are deceptively simple. I spent 3 years pondering such questions before finding some explanations I could accept. Look for a paper by Johan Leander in the Journal of the Acoustical Society of America, late -95 or -96, to become even more confused... Rune
Thank you for your guidance,

Of course it is the concept of "phase delay" which applies to a single
sinusoide.

That solves one problem.

But if now we consider a baseband signal (I am actually working with an
OFDM signal DVB-T standard 2k mode, at the baseband stage after making
IFFT of the symbols, and convolution with the pulse shape function). I
want to filter out all the frequencies which come from sampling at higher
speed (pulse shape sampled at fs=365 MHz) in the frequency domain and keep
only the signal of interest at baseband (0 to fmax=3.8 MHz).

I use a butterworth filter with cutoff frequency 18MHz and order 13.

From what I have read (cf
http://ccrma.stanford.edu/~jos/filters/Derivation_Group_Delay_Modulation.html)
I should check first that the phase response is linear between 0 and 3.8
MHz and if yes the delay of the signal after the filter should be equal to
the group delay taken at 0 frequency that is to say in the case of
butter[13,1/20] 57 samples!

Am I correct or am I missing again something?

If this is true I am still misunderstanding something since by refering to
the paper
http://www.ece.gatech.edu/research/labs/sarl/tutorials/OFDM/Tutorial_web.pdf#search=%22ofdm%20simulation%20using%20matlab%22
 it is said (page 9) that the delay produced by filtering is 64!!! I cannot
get this!

Thanks to let me know if you have further clear view on that point.

Gab