Function objective: Design an all-pass filter according to the described group delay to correct the group delay in the specified interval.
The iirgrpdelay function has the following seven usages:
1. [num,den] = iirgrpdelay(n,f,edges,a)
2. [num,den] = iirgrpdelay(n,f,edges,a,w)
3. [num ,den] = iirgrpdelay(n,f,edges,a,w,radius)
4, [num,den] = iirgrpdelay(n,f,edges,a,w,radius,p)
5, [num,den] = iirgrpdelay(n,f,edges,a,w,radius,p,dens)
6, [num,den] = iirgrpdelay(n,f,edges,a,w,radius,p,dens,initden)
7, [num ,den] = iirgrpdelay(n,f,edges,a,w,radius,p,dens,initden,tau)
Take the second [num,den] = iirgrpdelay(n,f,edges,a):
output : num is the IIR filter numerator, den is the IIR filter denominator Input
:
n is the filter order, f is the angular frequency range vector such as 0.3:0.001:0.6
edges is the passband range such as [0.3,0.6], a is the description The group delay difference as max(g)-g
is an example below:
clc;clear all;close all;
[n,d] = ellip(4,1,35,0.6); %椭圆滤波器(n,d为椭圆滤波器系数) 阶数:4 通带衰减(波纹)1dB 阻带衰减35dB 低通边界频率0.3
[GdH,w] = grpdelay(n,d); %求出群时延(GdH为群时延,w为角频率)
F = 0.3:0.001:0.6; %取0.3~0.6的角频率点
g = grpdelay(n,d,F,2); % Equalize the passband(g给0~0.3的群时延)
Gd = max(g)-g; %Gd为需要补偿的群时延量
% 采用iirgrpdelay函数全通滤波器
[num,den] = iirgrpdelay(20, F,[0.3 0.6], Gd); %返回20阶全通滤波器,num和den是系数。
[GdA,w] = grpdelay(num,den); %计算全通滤波器的群时延
% 画图
He1=dfilt.df2(num,den); %根据系数得到滤波器系统函数
He=dfilt.df2(n,d); %根据系数得到滤波器系统函数
He_all=dfilt.cascade(He,He1); %将两个滤波器级联得到新的滤波器
grpdelay(He) %显示未校正系统的群延迟
grpdelay(He1) %显示设计的IIR滤波器群延迟
grpdelay(He_all) %经过校正后的群延迟
Results:
It can be seen that the designed IIR filter can correct the group delay of the specified interval of the system, and the corrected group delay effect is very good; continue to
see how the iirgrpdelay function designs the IIR filter according to the given group delay , you can directly enter the open iirgrpdelay command in the command window. After opening, we can see the following iirgrpdelaymex function, but this function is packaged in c language or fortanyuyan into a mexw file. We cannot see the internal program, which is a pity.
[as,tau]=iirgrpdelaymex(s.denOrd,s.edges,s.f,s.des,s.wt,...
s.maxRadius,s.P,s.density,s.Ho,s.AS); %s.Ho is actually group delay estimate in this case