1、 实验二 信号的采样与重建一,实验目的(1)通过观察采样信号的混叠现象,进一步理解奈奎斯特采样频率的意义。(2)通过实验,了解数字信号采样转换过程中的频率特征。(3)对实际的 音频文件作内插和抽取操作,体会低通滤波器在内插和抽取中的作用。二,实验内容(1)采样混叠,对一个模拟信号 Va(t)进行等间采样,采样频率为200HZ,得到离散时间信号 V(n).Va(t)由频率为30Hz,150Hz,170Hz,250Hz,330Hz 的 5 个正弦信号的加权和构成。Va(t)=6cos(60pi*t)+3sin(300pi*t)+2cos(340pi*t)+4cos(500pi*t)+10sin(6
2、60pi*t)观察采样后信号的混叠效应。程序:clear,close all,t=0:0.1:20;Ts=1/2;n=0:Ts:20;V=8*cos(0.3*pi*t)+5*cos(0.5*pi*t+0.6435)-10*sin(0.7*pi*t);Vn=8*cos(0.3*pi*n)+5*cos(0.5*pi*n+0.6435)-10*sin(0.7*pi*n);subplot(221)plot(t,V),grid on,subplot(222)stem(n,Vn,.),grid on,0 5 10 15 20-40-20020400 5 10 15 20-40-2002040(2)输入信号
3、 X(n)为归一化频率 f1=0.043,f2=0.31 的两个正弦信号相加而成,N=100,按因子 M=2 作抽取:(1)不适用低通滤波器;(2)使用低通滤波器。分别显示输入输出序列在时域和频域中的特性。程序:clear;N=100;M=2;f1=0.043;f2=0.31;n=0:N-1;x=sin(2*pi*f1*n)+sin(2*pi*f2*n);y1=x(1:2:100);y2=decimate(x,M,fir);figure(1);stem(n,x(1:N);title(input sequence);xlabel(n);ylabel(fudu);figure(2);n=0:N/2
4、-1;stem(n,y1);title(output sequence without LP);xlabel(n);ylabel(fudu);figure(3);m=0:N/M-1;stem(m,y2(1:N/M);title(output sequence with LP);xlabel(n);ylabel(fudu);figure(4);h,w=freqz(x);plot(w(1:512),abs(h(1:512);title(frequency spectrum of the input sequence);xlabel(w);ylabel(fudu);figure(5);h,w=fre
5、qz(y1);plot(w(1:512),abs(h(1:512);title(frequency spectrum of the output sequence without LP);xlabel(w);ylabel(fudu);figure(6);h,w=freqz(y2);plot(w(1:512),abs(h(1:512);title(frequency spectrum of the output sequence without LP);xlabel(w);ylabel(fudu);0 10 20 30 40 50 60 70 80 90 100-2-1.5-1-0.500.51
6、1.52 input sequencenfudu0 5 10 15 20 25 30 35 40 45 50-2-1.5-1-0.500.511.52 output sequence without LPnfudu0 5 10 15 20 25 30 35 40 45 50-1.5-1-0.500.511.5 output sequence with LPnfudu0 0.5 1 1.5 2 2.5 3 3.505101520253035404550 frequency spectrum of the input sequencewfudu0 0.5 1 1.5 2 2.5 3 3.50510
7、15202530 frequency spectrum of the output sequence without LPwfudu0 0.5 1 1.5 2 2.5 3 3.50510152025 frequency spectrum of the output sequence without LPwfudu(3)输入信号X(n)为归一化频率f1=0.043, f2=0.31的两个正弦信号相加而成,长度N=50,内插因子为2.(1)不适用低通滤波器;(2)使用低通滤波器。分别显示输入输出序列在时域和频域中的特性。程序:clear,close all,N=50;L=2;f1=0.043;f2
8、=0.31;n=0:N-1;x=sin(2*pi*f1*n)+sin(2*pi*f2*n);figure(1);stem(n,x(1:N);title(input sequence);xlabel(n);ylabel(fudu);y1=zeros(1,N*2);y1(1:2:N*2)=x;figure(2);m=0:N*L-1;stem(m,y1(1:N*L);title(output sequence );xlabel(n);ylabel(fudu);y2=interp(x,L);figure(3);m=0:N*L-1;stem(m,y2(1:N*L);title(output sequen
9、ce);xlabel(n);ylabel(fudu);figure(4);h,w=freqz(x);plot(w(1:512),abs(h(1:512);title(frequency spectrum of the input sequence);xlabel(w);ylabel(fudu);figure(5);h,w=freqz(y1);plot(w(1:512),abs(h(1:512);title(frequency spectrum of the output sequence);xlabel(w);ylabel(fudu);figure(6);h,w=freqz(y2);plot(
10、w(1:512),abs(h(1:512);title(frequency spectrum of the output sequence );xlabel(w);ylabel(fudu);0 5 10 15 20 25 30 35 40 45 50-2-1.5-1-0.500.511.52 input sequencenfudu0 10 20 30 40 50 60 70 80 90 100-2-1.5-1-0.500.511.52 output sequence nfudu0 10 20 30 40 50 60 70 80 90 100-2-1.5-1-0.500.511.522.53 o
11、utput sequencenfudu0 0.5 1 1.5 2 2.5 3 3.5051015202530 frequency spectrum of the input sequencewfudu0 0.5 1 1.5 2 2.5 3 3.5051015202530 frequency spectrum of the output sequencewfudu0 0.5 1 1.5 2 2.5 3 3.50102030405060 frequency spectrum of the output sequence wfudu2 (3)令x(n)=cos(2*pi*f*n/fs),其中f/fs
12、=1/16,即每个周期内有16个点。试用MATLAB编程实现:1).作M=4倍的抽取,使每个周期变成4点。程序:clear,close all,N=100;M=4;n=0:N-1;x=cos(2*pi*n*(1/16);stem(n,x(1:N);title(input sequence);xlabel(n);ylabel(fudu);y1=x(1:4:100);y2=decimate(x,M,fir);figure(2);m=0:N/4-1;stem(m,y1); title(output sequence );xlabel(n);ylabel(fudu);figure(3);m=0:N/M
13、-1;stem(m,y2(1:N/M);title(output sequence);xlabel(n);ylabel(fudu);figure(4);h,w=freqz(x);plot(w(1:512),abs(h(1:512);title(frequency spectrum of the input sequence);xlabel(w);ylabel(fudu);figure(5);h,w=freqz(y1);plot(w(1:512),abs(h(1:512);title(frequency spectrum of the output sequence);xlabel(w);yla
14、bel(fudu);figure(6);h,w=freqz(y2);plot(w(1:512),abs(h(1:512);title(frequency spectrum of the output sequence );xlabel(w);ylabel(fudu);0 20 40 60 80 100-1-0.8-0.6-0.4-0.200.20.40.60.81 input sequencenfudu0 5 10 15 20 25-1-0.8-0.6-0.4-0.200.20.40.60.81 output sequence nfudu0 5 10 15 20 25-1.5-1-0.500.
15、511.5 output sequencenfudu0 0.5 1 1.5 2 2.5 3 3.50102030405060 frequency spectrum of the input sequencewfudu0 0.5 1 1.5 2 2.5 3 3.502468101214 frequency spectrum of the output sequencewfudu0 0.5 1 1.5 2 2.5 3 3.502468101214 frequency spectrum of the output sequence wfudu2).作 L=3 倍的插值,使每个周期变成 48 点。程序
16、:clear,close all,N=50;L=3;n=0:N-1;x=cos(2*pi*n*(1/16);figure(1);stem(n,x(1:N);title(input sequence);xlabel(n);ylabel(fudu);y1=zeros(1,N*3);y1(1:3:N*3)=x;figure(2);m=0:N*3-1;stem(m,y1(1:N*3);title(output sequence );xlabel(n);ylabel(fudu);y2=interp(x,L);figure(3);m=0:5:N*L-1;stem(m,y2(1:5:N*L);title(o
17、utput sequence);xlabel(n);ylabel(fudu);figure(4);h,w=freqz(x);plot(w(1:512),abs(h(1:512);title(frequency spectrum of the input sequence);xlabel(w);ylabel(fudu);figure(5);h,w=freqz(y1);plot(w(1:512),abs(h(1:512);title(frequency spectrum of the output sequence);xlabel(w);ylabel(fudu);figure(6);h,w=fre
18、qz(y2);plot(w(1:64),abs(h(1:64);title(frequency spectrum of the output sequence );xlabel(w);ylabel(fudu);0 5 10 15 20 25 30 35 40 45 50-1-0.8-0.6-0.4-0.200.20.40.60.81 input sequencenfudu0 50 100 150-1-0.8-0.6-0.4-0.200.20.40.60.81 output sequence nfudu0 50 100 150-1.5-1-0.500.511.5 output sequencen
19、fudu0 0.5 1 1.5 2 2.5 3 3.5051015202530 frequency spectrum of the input sequencewfudu0 0.5 1 1.5 2 2.5 3 3.5051015202530 frequency spectrum of the output sequencewfudu0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.401020304050607080 frequency spectrum of the output sequence wfudu(4).输入信号 x(n)为归一化频率分别是 f1=0.04,
20、f2=0.3 的正弦信号相加而成, N=50,内插因子为 5,抽取因子为 3,给出按有理因子 5/3 做采样率转换的输入输出波形。程序:clear,close all,N=50;M=3;L=5;f1=0.04;f2=0.3;n=0:N-1;x=sin(2*pi*f1*n)+sin(2*pi*f2*n);y=resample(x,L,M);figure(1);stem(n,x(1:N);title(input sequence);xlabel(n);ylabel(fudu);figure(2);m=0:N-1;stem(m,y(1:N); title(output sequence );xlab
21、el(n);ylabel(fudu);figure(3);h,w=freqz(x);plot(w(1:512),abs(h(1:512);title(frequency spectrum of the input sequence);xlabel(w);ylabel(fudu);figure(4);h,w=freqz(y);plot(w(1:512),abs(h(1:512);title(frequency spectrum of the output sequence );xlabel(w);ylabel(fudu);0 10 20 30 40 50-2-1.5-1-0.500.511.52 input sequencenfudu0 10 20 30 40 50-2-1.5-1-0.500.511.52 output sequence nfudu0 0.5 1 1.5 2 2.5 3 3.5051015202530 frequency spectrum of the input sequencewfudu0 0.5 1 1.5 2 2.5 3 3.5051015202530354045 frequency spectrum of the output sequence wfudu