过滤以后:T=0.0005
n=0:199
a1=20
a2=220
a3=750
f1=0.25*sin(2*pi*a1*n*T)+0.5*sin(2*pi*a2*n*T)+1*sin(2*pi*a3*n*T)
y=fft(f1,200)
stem(n,abs(y))
k=[zeros(1,20),ones(1,20),zeros(1,100),ones(1,50),zeros(1,10)]
y1=y.*k
stem(n,abs(y1))
第三题:
t=0:1.9:100;
x=cos(pi*t);
y=cos(9*pi*t);
y1=x.*y;
subplot(3,1,1),plot(t,y1)
y2=fft(y1,100);
n=0:99;
subplot(3,1,2),stem(n,y2)
y3=y1.*x;
subplot(3,1,3),plot(t,y3)
fp=0.5;
wp=2*pi*fp;
fs=2;
ws=2*pi*fs;
rp=10;
rs=50;
[N,Wn]=buttord(wp,ws,rp,rs,'s');
[b,a]=butter(N,Wn,'s');
w=0:500;
Hs=20*log10(abs(freqs(b,a,w)));
plot(w/(2*pi),Hs)
grid
xlabel('Frequency in Hz')
ylabel('Gain in DB')
<四>课程设计总结