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,
The input vectors are the coefficients for the numerator,
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
[gd,w] = grpdelay(b,a,n) returns
the group delay response of the discrete-time filter evaluated at
spaced points on the unit circle in the interval [0,π).
a positive integer. For best results, set
a value greater than the filter order.
[gd,w] = grpdelay(sos,n) returns the group
delay response for the second-order sections matrix,
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
grpdelay considers the input to be the
b. Each row of
to the coefficients of a second-order (biquad) filter. The ith
row of the
sos matrix corresponds to
bi(2) bi(3) ai(1) ai(2) ai(3)].
[gd,w] = grpdelay(d,n) returns the group
delay response for the digital filter,
designfilt to generate
on frequency-response specifications.
[gd,f] = grpdelay(...,n,fs) specifies
a positive sampling frequency
fs in hertz. It returns
the frequency points in hertz at which the group delay response is
between 0 and
[gd,w] = grpdelay(...,n,'whole') and
[gd,f] = grpdelay(...,n,'whole',fs) use
around the whole unit circle (from 0 to 2π,
or from 0 to
gd = grpdelay(...,w) and
gd = grpdelay(...,f,fs) return
the group delay response evaluated at the angular frequencies in
radians/sample) or in
f (in cycles/unit time),
fs is the sampling frequency.
vectors with at least two elements.
grpdelay(...) with no output
arguments plots the group delay response versus frequency.
grpdelay works for both real and complex
If the input to
grpdelay is single precision,
the group delay is calculated using single-precision arithmetic. The
gd, is single precision.
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')
designfilt to design a sixth-order Butterworth Filter with normalized 3-dB frequency rad/sample. Display its group delay response.
d = designfilt('lowpassiir','FilterOrder',6, ... 'HalfPowerFrequency',0.2,'DesignMethod','butter'); 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
where θ(ω) is the phase, or argument, of H(ejω).
grpdelay multiplies the filter coefficients
by a unit ramp. After Fourier transformation, this process corresponds