fir_lpf.m

来自「this a DSP program for FIR」· M 代码 · 共 34 行

M
34
字号
% for lowpass filter
fc=1000;fs=10000;
wc=2*fc/fs;
N1=11;
N2=(N1-1)/2
n1=[0: (N2-1)];
h1=sin(wc*pi*(n1-N2))./(pi*(n1-N2));
h2=wc; 
n2=[(N2+1): (N1-1)];
h3=sin(wc*pi*(n2-N2))./(pi*(n2-N2));
ha=[h1 h2 h3];
na=[n1 N2 n2];

f=figure;
set(f,'Name','lowpass filter design');
subplot(2,1,1);
plot(na,ha);
title('Impulse Response,N=11');
axis([0,12,-0.1,0.4]);
xlabel('time sample n');
ylabel('h(n)');
X1=fft(ha,128);
subplot(2,1,2);
plot(abs(X1));
title('Magnitude Response,N=11');
axis([0,60,0,1.1]);
xlabel('ω in units of \pi/N ');
ylabel('H(ω)');
grid




⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?