2

Despite,reading up on this I'm unable to find crystal clear clarity on the differences b/w phase and grpdelay functions and interpretation of grpdelay's output. I have designed a low pass butterworth filter having a cut off frequency of 0.04Hz. There is a delay in my filtered output compared to my original signal. I wish to know this delay. I used the grpdelay function in matlab (grpdelay(b,a,N/2) ). And this is the output i got.enter image description here. I read that grpdelay is supposed to give the phase responses as a function of frequencies. In my image, the cursor points to the cut-off freq. How exactly do I know the delay in my filtered output through this? Is it the corresponding value on the Y-axis?

Plotting the phasedelay(b,a), gave this as the output.enter image description here.Here,the phasedelay value at cut-off is different.

My question is, to figure out how much the filter has delayed the signal,which function do I use? And how do I interpret the output exactly, of that function?

Here is my original signal in blue and the filtered signal which has the delay in redenter image description here .enter image description here

userminerva
  • 73
  • 1
  • 7
  • I did read that yes, but still had a lingering doubt. Phase delay gives me the phase angle at a particular point in frequency whereas group delay gives me the rate of change of phase around that point. So, in answer to my question, phasedelay function is the one I should go for? To just figure out how much the filter delayed the signal i mean. – userminerva Jun 30 '14 at 08:03
  • 1
    also take a look at what wikipedia says about it . i am pretty sure what is said in that introduction is correct. phase delay is about how much time the sinusoid (at some known frequency) is delayed and group delay is about how much time the envelope governing that sinusoid (of the same frequency) is delayed. they are not necessarily delayed the same amount of time (but they are if it's a linear-phase filter, then group and phase delay is the same and constant for all frequencies). – robert bristow-johnson Jun 30 '14 at 20:12
  • Do these help? http://en.wikipedia.org/wiki/File:Wave_group.gif http://en.wikipedia.org/wiki/File:Two-frequency_beats_of_a_non-dispersive_transverse_wave_%28animated%29.gif – endolith Jul 01 '14 at 02:06
  • I know this is a very old post, but just in case someone jumps in with the same problem, try to apply the filter twice and in the second time, reverse the time series. This fixed most of the delay. Source: https://www.mathworks.com/help/signal/ref/filtfilt.html – iury simoes-sousa May 25 '23 at 20:10

1 Answers1

7

If you are looking for a frequency-independent delay applied to any given input signal by the filter (apart from amplifying and attenuating certain frequency components), then you won't be able to find it because there is no such delay. As you can see in your plots, group delay and phase delay are generally frequency dependent. Furthermore, for general input signals, the terms group delay and phase delay have no meaning.

There are two cases for which the terms group delay and phase delay have a clear meaning. The first is for narrow-band input signals

$$x(t)=a(t) \cos(\omega_0 t)$$

where $a(t)$ is a low-pass signal. If the system has an approximately constant amplitude response in the frequency range of $x(t)$ (i.e., around $\omega_0$) which is $\left|H(j \omega_0)\right|$, and if its phase is approximately linear in this frequency range, then it can be shown that the output signal is approximately given by

$$y(t) \approx \left| H(j \omega_0) \right| a(t-\tau_g(\omega_0)) \cos\left( \omega_0(t-\tau_\phi(\omega_0)) \right)\tag{1}$$

where $\tau_g(\omega_0)$ is the system's group delay evaluated at the carrier frequency $\omega_0$, and $\tau_\phi(\omega_0)$ is the phase delay at $\omega_0$. So in this case the group delay is the delay of the envelope, whereas the phase delay equals the delay of the carrier. A special example of such a narrow band input signal is a pure sinusoid. From (1) it is clear that the delay of a pure sinusoid when passing through a linear time-invariant (LTI) filter equals the phase delay evaluated at the sinusoid's frequency (and not the group delay). Note that in the case of a pure sinusoid (i.e. $a(t)=\mbox{const}$), Equation (1) becomes exact for any LTI system.

The other case where these terms are meaningful is when the system has exactly linear phase. This is only possible for FIR systems. For FIR filters with even symmetry of the impulse response, the group delay and the phase delay are equal and constant. In this case, they simply specify the delay of the input signal. This is possible because both group delay and phase delay are constant, i.e. frequency independent.

From your question, I believe that you are looking for such a delay. However, as explained above, such delay only exists for linear-phase FIR systems, not for the Butterworth filter you are considering.

robert bristow-johnson
  • 20,661
  • 4
  • 38
  • 76
Matt L.
  • 89,963
  • 9
  • 79
  • 179
  • yes, butterworth,iir, filters do not have linear phase as you said,and since the phase delay and group delay are not equal and constant, and therefore are frequency dependant, how can i calculate the delay due to this filter? – userminerva Jun 30 '14 at 09:13
  • 1
    @usersandie: You can't, unless you define exactly what you are talking about. What exactly do you mean by delay? The time it takes until you get the first non-zero output sample (assuming zero initial conditions), the delay of the envelope (if there is any), the delay of the frequency component at 1000Hz, etc.? – Matt L. Jun 30 '14 at 09:19
  • @usersandie: You could provide a plot of your input and output signals, specifying the delay that you mean. But again, note that whatever you define will most likely only be valid for a certain class of input signals. – Matt L. Jun 30 '14 at 09:22
  • Also,i did read the first case as well and tried to apply it to my signal. The frequency response of the filtered signal shows a constant magnitude of 1 till about 0.01Hz(pass band).After which is the transition phase through cut-off freq to the stopband.The phase response isn – userminerva Jun 30 '14 at 09:25
  • @usersandie: For sufficiently narrow-band input signals the phase response is approximately linear in the given band, and the approximation (1) is valid. I.e. for a narrow-band signal in the passband of the filter, you can use this approximation. Note however, that in your case the signal must have a very small bandwidth because your filter has a narrow passband. – Matt L. Jun 30 '14 at 09:28
  • @usersandie: Try it with a pure sinusoid, and you'll see that it works (in this case you need to use the phase delay at the sinusoid's frequency). – Matt L. Jun 30 '14 at 09:29
  • L:I think i understand. If my signal had frequency components which were within the passband alone, then the approximation works? – userminerva Jun 30 '14 at 09:43
  • @usersandie: Yes, and the smaller the bandwidth of the input signal, the better the approximation works. – Matt L. Jun 30 '14 at 09:44
  • @usersandie: Looking at the plots you've added, it should be possible to estimate the delay by using the phase delay evaluated at the frequency of the strong sinusoidal component of the input signal. – Matt L. Jun 30 '14 at 09:46
  • Thanks Matt. So I plot my phasedelay(b,a,n) anyway('b' and 'a' being filter co-effs) and at the frequency of the strong sinusoidal(0.036Hz as in my freqresponse plot),I assume the Y-axis value as an estimation of the delay? In conclusion I realised that unless it is an FIR filter(linear phase) or the case-1,measurement of delay is not possible. correct? – userminerva Jun 30 '14 at 10:24
  • @usersandie: Yes, that should give you a reasonable estimate. In the general case the computation of a delay which is valid for all input signals is usually not possible. – Matt L. Jun 30 '14 at 10:51
  • MattL. and @usersandie, especially for low-pass filters, often we say "the delay of this filter is" whatever the group and phase delay is at DC (0 Hz). and, even for non-linear phase filters, where group and phase delays aren't generally the same, they are the same at DC. (at least if there is no polarity inversion.) – robert bristow-johnson Jun 30 '14 at 20:25
  • "then you won't be able to find it because there is no such delay" ... unless you're using Bessel filters? – endolith Jun 30 '14 at 21:48
  • @endolith, i don't think it's Bessel filters (they have very flat group delay from DC up to approximately their resonant frequency), but it's not totally frequency independent. but a linear-phase FIR with symmetrical tap coefficients, that is such a delay, even in the strict sense of that concept. but i would say that, for lowpass filters, the group and phase delay at DC (at DC it's the two delays are the same value) might be legitimately called "the delay property of this filter". maybe not, but i think that's what we do most often. – robert bristow-johnson Jun 30 '14 at 22:51