フィルターのクリア

How to design a fir filter with arbitrary frequency response and phase using cfirpm function?

1 回表示 (過去 30 日間)
Song Shaoqin
Song Shaoqin 2023 年 4 月 25 日
編集済み: Song Shaoqin 2023 年 4 月 25 日

clc
clear
S = load('演示曲线—全频.txt');
n = 128;
t=0:1:n-1;
f=t./n;

w = S;
b = cfirpm(n,f,@fresp,w,'even');
b = b(1:n/2);
fvtool(b);

function [dh,dw]=fresp(n,f,gf,w)

x1 = w(:,1); %频率 hz
x2 = w(:,2); %幅度值 db
x3 = w(:,3); %相位 度

x1=[0;x1];
x2=[0;x2];
x3=[0;x3];

FS = 48000; %采样频率

x1_f = x1./(FS/2);
x2_a = power(10, x2 ./ 20);

x3_p = unwrap(x3);
x3_p = x3_p*pi/180;

plot(x1_f,x2_a,x1_f,x3_p); % 期望频响,相位曲线

a2 = interp1(x1_f,x2_a,f,'spline'); % 幅度插值
p2 = interp1(x1_f,x3_p,f,'spline'); % 相位插值

a3 = interp1(f,a2,gf,'spline'); % 幅度插值
p3 = interp1(f,p2,gf,'spline'); % 相位插值

dh = 2 * a3.* exp(1i*p3);
dw=gf;

end

The above is the process of using cfirpm function to design fir filter for arbitrary frequency response and phase, but I found the result is not correct, may I ask what went wrong?

回答 (0 件)

カテゴリ

Help Center および File Exchange数字滤波器设计 についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!