华工DSP实验考试报告.docx
《华工DSP实验考试报告.docx》由会员分享,可在线阅读,更多相关《华工DSP实验考试报告.docx(14页珍藏版)》请在冰豆网上搜索。
华工DSP实验考试报告
DSP考试实验报告
姓名
学号
专业班级
电信
提交日期
2014年12月18日
一、频分复用
1选择3个不用频段的信号,画出其频谱
%1.Èý¸öƵÂÊ·Ö±ðΪ150Hz,300HzºÍ450HzµÄÐźÅ
t=0:
0.001:
1;
x1=cos(2*pi*150*t);
x2=cos(2*pi*300*t);
x3=cos(2*pi*450*t);
y1=fft(x1,256);
y2=fft(x2,256);
y3=fft(x3,256);
f=1000*(0:
128)/256;
figure
(1);
subplot(3,1,1);
plot(f,abs(y1(1:
129)));
xlabel('频率');
ylabel('幅度');
subplot(3,1,2);
plot(f,abs(y2(1:
129)));
xlabel('频率');
ylabel('幅度');
subplot(3,1,3);
plot(f,abs(y3(1:
129)));
2将三路信号合成一路信号,画出合成信号的时域和频域波形
%2.3路信号合成1路信号
figure
(2);
x=x1+x2+x3;
stem(t,x);
subplot(2,1,1);
stem(t,x);
plot(x(1:
128));
xlabel('t');
ylabel('y');
title('时域');
subplot(2,1,2);
y=fft(x,256);
plot(f,abs(y(1:
129)));
xlabel('频率');
ylabel('幅度');
title('频域');
3将合成信号分别通过设计好的数字滤波器,分离出原来的三路信号,分
析得到的三路信号的时域波形和频谱,与原始的三路信号进行比较说明频
分复用的特点
4将所用滤波器的频谱画出来
%低通
t=0:
0.001:
1;
x1=cos(2*pi*150*t);
x2=cos(2*pi*300*t);
x3=cos(2*pi*450*t);
x=x1+x2+x3;
y1=fft(x,256);
fp=200;
fs=1200;
ft=4000;
rp=1;
rs=40;
T=1/ft;
wp=2*pi*fp/ft;
ws=2*pi*fs/ft;
omegap=(2/T)*tan(wp/2);
omegas=(2/T)*tan(ws/2);
[N,wn]=buttord(omegap,omegas,rp,rs,'s');
[num,den]=butter(N,wn,'low','s');
[numz,denz]=bilinear(num,den,ft);
figure(3)
freqz(numz,denz)
y=filter(numz,denz,x);
y2=fft(y,256);
f=1000*(0:
128)/256;
subplot(4,1,3);
plot(f,abs(y1(1:
129)));
xlabel('频率');
ylabel('幅度');
title('原始信号频域');
subplot(4,1,4);
plot(f,abs(y2(1:
129)));
xlabel('频率');
ylabel('幅度');
title('滤波后频域');
%带通
t=0:
0.001:
1;
x1=cos(2*pi*150*t);
x2=cos(2*pi*300*t);
x3=cos(2*pi*450*t);
x=x1+x2+x3;
y1=fft(x,256);
fp1=900;fp2=1300;
fs1=600;fs2=1500;
ft=4000;
rp=1;
rs=40;
T=1/ft;
wp=2*pi*[fp1fp2]/ft;
ws=2*pi*[fs1fs2]/ft;
omegap=(2/T)*tan(wp/2);
omegas=(2/T)*tan(ws/2);
[N,wn]=buttord(omegap,omegas,rp,rs,'s');
[num,den]=butter(N,wn,'bandpass','s');
[numz,denz]=bilinear(num,den,ft);
figure(5)
freqz(numz,denz)
y=filter(numz,denz,x);
y2=fft(y,256);
f=1000*(0:
128)/256;
subplot(4,1,3);
plot(f,abs(y1(1:
129)));
xlabel('频率');
ylabel('幅度');
title('原始信号频域');
subplot(4,1,4);
plot(f,abs(y2(1:
129)));
xlabel('频率');
ylabel('幅度');
title('滤波后频域');
%高通
t=0:
0.001:
1;
x1=cos(2*pi*150*t);
x2=cos(2*pi*300*t);
x3=cos(2*pi*450*t);
x=x1+x2+x3;
y1=fft(x,256);
fp=1400;
fs=1500;
ft=4000;
rp=1;
rs=40;
T=1/ft;
wp=2*pi*fp/ft;
ws=2*pi*fs/ft;
omegap=(2/T)*tan(wp/2);
omegas=(2/T)*tan(ws/2);
[N,wn]=buttord(omegap,omegas,rp,rs,'s');
[num,den]=butter(N,wn,'high','s');
[numz,denz]=bilinear(num,den,ft);
figure(4)
freqz(numz,denz)
y=filter(numz,denz,x);
y2=fft(y,256);
f=1000*(0:
128)/256;
subplot(4,1,3);
plot(f,abs(y1(1:
129)));
xlabel('频率');
ylabel('幅度');
title('原始信号频域');
subplot(4,1,4);
plot(f,abs(y2(1:
129)));
xlabel('频率');
ylabel('幅度');
title('滤波后频域');
频率复用系统的优点:
信道复用率高,允许复用的路数多,同时它的分
路也很方便。
二、音频信号分析
1读出所给音频信号,确定该音频信号的采样率=44100Hz和量化比特数=16.
画出该音频信号的时域波形和频谱图
2对该音频信号以间隔M=2进行采样,回放音频信号,感觉和原来有什么不
同?
N1=100000;
N2=600000;
[x,fs,bits]=wavread('C:
\Users\lc\Desktop\laughing.wav',[N1,N2]);
wavwrite(x,44100,'C:
\Users\lc\Desktop\laughingnew.wav');
Nx=N1:
N2;
figure;
subplot(2,1,1);
plot(Nx,x(:
1));
title('C1');
subplot(2,1,2);
plot(Nx,x(:
2));
title('C2');
figure;
subplot(2,1,1);
X1=fft(x(:
1));
plot(Nx,fftshift(X1));
title('C1');
subplot(2,1,2);
X2=fft(x(:
2));
plot(Nx,fftshift(X2));
title('C2');
x1c=x(1:
2:
length(x),1);
x2c=x(1:
2:
length(x),2);
fori=1:
length(x)/2
xnew(i,1)=x1c(i);
xnew(i,2)=x2c(i);
end
wavwrite(xnew,40000,'C:
\Users\lc\Desktop\laughingnewoo.wav');
采样后的音频信号比原来的速度更快,而且音调更尖锐。
3你想怎么解决?
为什么?
在采样后的每个点中间插入相邻两点的平均值以恢复原信号。
4画出解决前后音频信号的波形及频谱
fori=1:
2:
length(x)-10
xori(i,1)=x1c((i+1)/2);
xori(i,2)=x2c((i+1)/2);
xori(i+1,1)=0.5*(x1c((i+1)/2)+x1c((i+3)/2));
xori(i+1,2)=0.5*(x2c((i+1)/2)+x2c((i+3)/2));
end
wavwrite(xori,40000,'laughing_ori.wav');
%%4
figure;
subplot(3,1,1);
plot(1:
length(x)-1,x(1:
length(x)-1,:
));
title('origin');
subplot(3,1,2);
plot(1:
2:
length(x)-1,xnew);
title('DownSampling');
subplot(3,1,3);
plot(1:
length(x)-9,xori);
title('Regain');
figure;
subplot(3,1,1);
plot(1:
length(x)-1,abs(fftshift(fft(x(1:
length(x)-1,:
)))));
title('origin');
subplot(3,1,2);
plot(1:
2:
length(x)-1,abs(fftshift(fft(xnew))));
title('DownSampling');
subplot(3,1,3);
plot(1:
length(x)-9,abs(fftshift(fft(xori))));
title('Regain');
时间问题,波形实在出不来.
5播放解决前后的音频信号的波形及频谱