clear
fs=500;
t=0:pi/200:pi/1.5;
x=sin(t)+sin(3*t)+1;
x_=x';
wp=1.5/500;%截止频率,以下的频率可以通过 
ws=5/500;%被滤除
Rp=1;
As=10;
subplot(311);
plot(t,x);
title('sin(t)+sin(5*t)+4');
%N滤波阶数,Wn代表滤波器的截止频率

[N,wc]=buttord(wp,ws,Rp,As);

[B,A]=butter(N,wc,'low');

[H,W]=freqz(B,A);

y=filter(B,A,x);

subplot(312);
test=sin(t);
plot(t,test);
%plot(W,abs(H));

title('y=sin(x)');

subplot(313);

plot(t,y)

title('低通滤波');