Next  |  Prev  |  Up  |  Top  |  Index  |  JOS Index  |  JOS Pubs  |  JOS Home  |  Search

## Group Delay Computation: grpdelay.m

Figure J.8 gives a listing of a matlab program for computing the group delay of an IIR digital filter using the method described in §7.6.6.

In Matlab with the Signal Processing Toolbox installed, (or Octave with the Octave Forge package installed), say 'help grpdelay' for usage documentation, and say 'type grpdelay' to additionally see test, demo, and plotting code. Here, we include only the code relevant to computation of the group delay itself.

 ```function [gd,w] = grpdelay(b,a,nfft,whole,Fs) if (nargin<1 || nargin>5) usage("[g,w]=grpdelay(b [, a [, n [,'whole'[,Fs]]]])"); end if nargin<5 Fs=0; % return w in radians per sample if nargin<4, whole=''; elseif ~isstr(whole) Fs = whole; whole = ''; end if nargin<3, nfft=512; end if nargin<2, a=1; end end if strcmp(whole,'whole')==0, nfft = 2*nfft; end w = 2*pi*[0:nfft-1]/nfft; if Fs>0, w = Fs*w/(2*pi); end oa = length(a)-1; % order of a(z) oc = oa + length(b)-1; % order of c(z) c = conv(b,fliplr(a)); % c(z) = b(z)*a(1/z)*z^(-oa) cr = c.*[0:oc]; % derivative of c wrt 1/z num = fft(cr,nfft); den = fft(c,nfft); minmag = 10*eps; polebins = find(abs(den)

Next  |  Prev  |  Up  |  Top  |  Index  |  JOS Index  |  JOS Pubs  |  JOS Home  |  Search

[How to cite this work]  [Order a printed hardcopy]  [Comment on this page via email]