Using iirgrpdelay function to design all-pass filter to correct system phase

Function objective: Design an all-pass filter to correct the phase of the specified interval according to the described group delay.
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;
load B_S;S=B_S;
load B_G;G=B_G;
H = dfilt.df2sos(B_S,B_G);
F=0.2:0.001:0.9;
g = grpdelay(H,F,2);   % Equalize the passband(g给0.2~0.9的群时延)
Gd = max(g)-g;          %Gd为需要补偿的群时延量
% Design the allpass delay equalizer
[num,den] = iirgrpdelay(20, F,[0.2 0.9], Gd);      %返回20阶全通滤波器,num和den是系数。
[GdA,w] = grpdelay(num,den);                    %计算全通滤波器的群时延
% 画图
He1=dfilt.df2(num,den);
He_all=dfilt.cascade(H,He1);
grpdelay(H)
grpdelay(He1)
grpdelay(He_all)  

Experimental results:
insert image description here
insert image description here
insert image description here
It can be seen that the phase-frequency response of the corrected system is close to a straight line, approximately linear, and the correction effect is very good.

Guess you like

Origin blog.csdn.net/qq_45362665/article/details/130237493