3 设 计 内 容
3.1 设计产生三个信号
通过Matlab软件自己编程产生三个同频带不同频率的模拟信号,编程如下。
t=-1:0.001:1; n=1:256; N=512; fs=1000;
x1=cos(150*pi*t);
f1=n*fs/N; figure(1);
subplot(3,1,1) plot(x1);
title('x1的时域波形');
xlabel('x1的时间');ylabel('x1的幅值'); axis([0,100,-1,1])
x2=cos(320*pi*t); subplot(3,1,2) plot(x2);
title('x2的时域波形');
xlabel('x2的时间');ylabel('x2的幅值'); axis([0,100,-1,1])
x3=cos(450*pi*t); subplot(3,1,3) plot(x3);
title('x3的时域波形');
xlabel('x3的时间');ylabel('x3的幅值'); axis([0,100,-1,1])
三个信号的时域波形:
3.2对三个信号进行FFT变换
通过Matlab编程对产生的三个信号进行FFT变换,从而生成频谱波形图。
y1=fft(x1,512); figure(2);
subplot(3,1,1)
plot(f1,abs(y1(1:256))); title('x1的频域波形');
xlabel('x1的频率(Hz)');ylabel('x1的幅值'); axis([0,500,0,250])
y2=fft(x2,512); subplot(3,1,2)
plot(f1,abs(y2(1:256))); title('x2的频域波形');
xlabel('x2的频率(Hz)');ylabel('x2的幅值'); axis([0,500,0,250])
y3=fft(x3,512); subplot(3,1,3)
plot(f1,abs(y3(1:256))); title('x3的频域波形');
xlabel('x3的频率(Hz)');ylabel('x3的幅值'); axis([0,500,0,250])
三个信号的频域波形:
3.3三个信号的叠加的时域和频域
x=x1+x2+x3; figure(3)
subplot(211); plot(x(1:100));
title('三个信号叠加的时域波形'); y=fft(x,512); subplot(212);
plot(f1,abs(y(1:256))); title('三个信号叠加的频谱') axis([0,600,0,250])
3.4 滤波器设计
3.4.1低通滤波器设计
本次试验的三个频率分别为75、160、225,所以低通滤波器设计如下:
Wp=2*pi*75;Ws=2*pi*100;Rp=1;As=30; [N,wc]=buttord(Wp,Ws,Rp,As,'s'); [b,a]=butter(N,wc,'s');
k=1:512;fk=0:1000/1024:1000; wk=2*pi*fk;
Hk=freqs(b,a,wk); figure(4);
plot(fk,abs(Hk));grid on;
xlabel('频率(Hz)');ylabel('幅度'); axis([0,200,0,1.1])
低通滤波器频域图:
3.4.2 带通滤波器2设计
该滤波器主要用于滤出信号X2即160的频率,所以滤波器的设计如下:
wp=2*pi*[140,200]; ws=2*pi*[120,230]; Rp=1; As=30;
[N,wc]=buttord(wp,ws,Rp,As,'s'); [B1,A1]=butter(N,wc,'s'); k=0:511;
fk=0:1000/512:1000; wk=2*pi*fk;
Hk=freqs(B1,A1,wk);
figure(6)
plot(fk,20*log10(abs(Hk))); grid on
title('带通滤波器的频响2') xlabel('频率(Hz)'); ylabel('幅度(dB)')
axis([100,400,-40,5])
3.4.3 带通滤波器3设计
该滤波器主要用于滤出信号X3即225的频率,所以滤波器的设计如下:
wp=2*pi*[260,320]; ws=2*pi*[240,350]; Rp=1; As=30;
[N,wc]=buttord(wp,ws,Rp,As,'s'); [B2,A2]=butter(N,wc,'s'); k=0:511;
fk=-1000:1000/512:1000; wk=2*pi*fk;
Hk=freqs(B2,A2,wk);