?? fir_design_win.m
字號:
% Name:FIR_design_win.m
clear,close all;
f=20000;%input('Type in the samping fequency f=:');
fp=input('Type in the passband edge frequency (in Hz) fp=');
fs=input('Type in the passband edge frequency (in Hz) fs=');
wp=fp*2*pi/f;ws=fs*2*pi/f;
wc=(wp+ws)/2;
L=ceil(4*pi/(ws-wp));
n=0:L-1;
%w=u(n)-u(n-L);%Rectangle window,
w=0.5*(1-cos(2*pi*n/(L-1))).*(u(n)-u(n-L));%Hanning window
h=(wc/pi)*sin(wc*(n-ceil(L/2)+eps+1))./(wc*(n-ceil(L/2)+eps+1)).*w;
%=======================================================================
N=2000;
H=fft(h,N);
H=H/max(abs(H));
W=0:f/N:f-f/N;
%=======================================================================
subplot(222)
plot(W,abs(H)),title('The magnitude response of the FIR filter')
axis([0,1.5*fs,0,max(abs(H))]),grid on;
%=========================================================
subplot(224)
plot(W,angle(H))
axis([0,1.5*fs,-pi,pi]),grid on;
title('The phase response of the FIR filter'),xlabel('Frequency (Hz)')
%======================================================
subplot(223)
plot(W,20*log10(abs(H)));
axis([0,1.5*fs,-100,0]),grid on;
title('The frequency response in dB'),
xlabel('Frequency (Hz)')
%======================================================
subplot(221)
stem(n,h,'.'),
axis([0,L-1,min(h),max(h)]),grid on;
title('The impulse response of the FIR filter')
xlabel('Index n')
%=================================================
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -