Average filter delay (group delay)
[gd,w] = grpdelay(b,a)
[gd,w] = grpdelay(b,a,n)
[gd,w] = grpdelay(sos,n)
[gd,w] = grpdelay(d,n)
[gd,f] = grpdelay(...,n,fs)
[gd,w] = grpdelay(...,n,'whole')
[gd,f] = grpdelay(...,n,'whole',fs)
gd = grpdelay(...,w)
gd = grpdelay(...,f,fs)
[gd,w] = grpdelay(b,a) returns the group delay response, gd, of the discrete-time filter specified by the input vectors, b and a. The input vectors are the coefficients for the numerator, b, and denominator, a, polynomials in z-1. The Z-transform of the discrete-time filter is
The filter's group delay response is evaluated at 512 equally spaced points in the interval [0,π) on the unit circle. The evaluation points on the unit circle are returned in w.
[gd,w] = grpdelay(sos,n) returns the group delay response for the second-order sections matrix, sos. sos is a K-by-6 matrix, where the number of sections, K, must be greater than or equal to 2. If the number of sections is less than 2, grpdelay considers the input to be the numerator vector, b. Each row of sos corresponds to the coefficients of a second-order (biquad) filter. The ith row of the sos matrix corresponds to [bi(1) bi(2) bi(3) ai(1) ai(2) ai(3)].
[gd,w] = grpdelay(d,n) returns the group delay response for the digital filter, d. Use designfilt to generate d based on frequency-response specifications.
[gd,f] = grpdelay(...,n,fs) specifies a positive sampling frequency fs in hertz. It returns a length-n vector, f, containing the frequency points in hertz at which the group delay response is evaluated. f contains n points between 0 and fs/2.
gd = grpdelay(...,w) and gd = grpdelay(...,f,fs) return the group delay response evaluated at the angular frequencies in w (in radians/sample) or in f (in cycles/unit time), respectively, where fs is the sampling frequency. w and f are vectors with at least two elements.
grpdelay works for both real and complex filters.
Design a Butterworth filter of order 6 with normalized 3-dB frequency rad/sample. Use grpdelay to display the group delay.
[z,p,k] = butter(6,0.2); sos = zp2sos(z,p,k); grpdelay(sos,128)
Plot both the group delay and the phase delay of the system on the same figure.
gd = grpdelay(sos,512); [h,w] = freqz(sos,512); pd = -unwrap(angle(h))./w; plot(w/pi,gd,w/pi,pd), grid xlabel 'Normalized Frequency (\times\pi rad/sample)' ylabel 'Group and phase delays' legend('Group delay','Phase delay')
Use designfilt to design a sixth-order Butterworth Filter with normalized 3-dB frequency 0.2. Display its group delay response.
d = designfilt('lowpassiir','DesignMethod','butter', ... 'FilterOrder',6,'HalfPowerFrequency',0.2); grpdelay(d)
The group delay response of a filter is a measure of the average delay of the filter as a function of frequency. It is the negative first derivative of the phase response of the filter. If the frequency response of a filter is H(ejω), then the group delay is
grpdelay multiplies the filter coefficients by a unit ramp. After Fourier transformation, this process corresponds to differentiation.