📄 fir_example.m
字号:
figure('position',[10 10 800 500],'name','FIR设计举例');
b1_sub={'低通,Hamming 窗'
'低通,Kaiser 窗'
'带通'
'带阻'
'微分器'
'希尔伯特变换器'};
b1 = uicontrol('style','popupmenu',...
'position',[100 450 300 25],...
'string',b1_sub);
subplot(1,1,1);
wp = 0.2*pi;
ws = 0.3*pi;
tr_width = ws - wp;
M = ceil(6.6*pi/tr_width)+1
n = [0:1:M-1];
wc = (ws+wp)/2;
hd = ideal_lp(wc,M);
w_ham = (hamming(M))';
h = hd.*w_ham;
[db,mag,pha,grd,w] = freqz_m(h,[1]);
delta_w = 2*pi/1000;
Rp = -(min(db(1:1:wp/delta_w+1)))
As = -round(max(db(ws/delta_w+1:1:501)))
subplot(3,2,3);
stem(n,hd);
title('Ideal Impulse Response');
axis([0 M-1 -0.1 0.3]);
xlabel('n');
ylabel('hd(n)');
subplot(3,2,4);
stem(n,w_ham);
title('Hamming Window');
axis([0 M-1 0 1.1]);
xlabel('n');
ylabel('hd(n)');
subplot(3,2,5);
stem(n,h);
title('Magnitude Response in dB');
axis([0 M-1 -0.1 0.3]);
xlabel('n');
ylabel('h(n)');
subplot(3,2,6);
plot(w/pi,db);
title('Magnitude Response in dB');grid
axis([0 1 -100 10]);
xlabel('frequency in pi units');
ylabel('Decibels')
set(b1,'Callback','FIR_example_sub');
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -