clc
clear
close all
N=15;
wc=pi/4;
alpha=(N-1)/2;
n=0:1:N-1;
m=n-alpha+eps;
hd=sin(wc*m)./(pi*m);
wn=(hamming(N))';
h=hd.*wn;
figure(1)
freqz(h,1);title('N=15时滤波器频率特性')
figure(2)
t=0:0.01:5-0.01;
x=sin(2*pi*t);
x1=sin(40*pi*t);
x2=x+x1;
y=filter(h,2,x2);
subplot(211);
plot(x2);title('加噪后输入函数波形')
subplot(212);
plot(y);title('滤波后输入函数波形')