数字信号处理课程设计报告(2)

数字信号处理课程设计报告(2)本文简介:通信与信息工程学院数字信号处理课程设计班级:电子信息科学与技术姓名:学号:指导教师:设计时间:成绩:评语:通信与信息工程学院二〇一三年题目一采样定理的验证1.设,利用filter函数求出(其中*为线性卷积)的前50个样本,并作图。(1)n=0:49;xn=0.8.^n;B=1;A=[1,-0.8];
数字信号处理课程设计报告(2)本文内容:
通信与信息工程学院
数字信号处理课程设计
班
级:
电子信息科学与技术
姓
名:
学
号:
指导教师:
设计时间:
成
绩:
评
语:
通信与信息工程学院
二〇一三年
题目一
采样定理的验证
1.
设,利用filter函数求出(其中*为线性卷积)的前50个样本,并作图。
(1)
n=0:49;
xn=0.8.^n;
B=1;
A=[1,-0.8];
yn=filter(B,A,xn);
stem(n,yn)
grid
on;
xlabel(
n
);
ylabel(
yn=x(n)*x(n)
)
2.考虑模拟信号,间隔采样得到。
(1)对每一个画出。
(2)采用内插从样本重建模拟信号,并从图中求出在中的频率(不管末端效果)。
(3)采用三次样条内插从样本重建模拟信号,并从图中求出在中的频率。
(1)
clc;
t=0:0.001:1;Ts1=0.01;N1=1/Ts1;n1=0:N1;
xn1=sin(20*pi*n1*Ts1);
subplot(3,1,1);
stem(n1,xn1,.
);axis([0
100
-1
1]);
xlabel(
n
);ylabel(
x_1(n)
);title(
Ts=0.01
);
t=0:0.001:1;Ts2=0.05;N2=1/Ts2;n2=0:N2;
xn2=sin(20*pi*n2*Ts2);
subplot(3,1,2);
stem(n2,xn2,.
);axis([0
20
-1
1]);
xlabel(
n
);ylabel(
x_2(n)
);title(
Ts=0.05
);
t=0:0.001:1;Ts3=0.1;N3=1/Ts3;n3=0:N3;
xn3=sin(20*pi*n3*Ts3);
subplot(3,1,3);
stem(n3,xn3,.
);axis([0
10
-1
1]);
xlabel(
n
);ylabel(
x_3(n)
);title(
Ts=0.1
);
(2)
t=0:0.001:1;T=0.1;
xt=sin(20*pi*t);subplot(4,1,1);plot(t,xt);
title(
xt原图
);xlabel(
t
);ylabel(
xt
);grid
on;
Ts1=0.01;n1=0:100;t1=0:Ts1:1;xn1=sin(20*pi*n1*Ts1);
tn1=ones(length(n1),1)*t1-n1Ts1*ones(1,length(t1));%ones(M,N):生成M*N大小的全1矩阵
yt1=xn1*sinc(tn1*pi/Ts1);subplot(4,1,2);plot(t1,yt1);axis([0
1
-1
1]);
title(
sinc内插0.01恢复的xt1图
);xlabel(
n
);ylabel(
xt1
);grid
on;
Ts2=0.05;n2=0:20;t2=0:Ts2:1;xn2=sin(20*pi*n2*Ts2);
tn2=ones(length(n2),1)*t2-n2Ts2*ones(1,length(t2));
yt2=xn2*sinc(tn2*pi/Ts2);subplot(4,1,3);plot(t2,yt2);axis([0
1
-1
1]);
title(
sinc内插0.05恢复的xt2图
);xlabel(
n
);ylabel(
xt2
);grid
on;
Ts3=0.1;n3=0:10;t3=0:Ts3:1;xn3=sin(20*pi*n3*Ts3);
tn3=ones(length(n3),1)*t3-n3Ts3*ones(1,length(t3));
yt3=xn3*sinc(tn3*pi/Ts3);subplot(4,1,4);plot(t3,yt3);axis([0
1
-1
1]);
title(
sinc内插0.1恢复的xt3图
);xlabel(
n
);ylabel(
xt3
);grid
on;
(3)
Ts1=0.01;Fs=1/Ts1;
xa1=spline(Ts1*n1,xn1,t);
subplot(3,1,1);plot(t,xa1);axis([0,1,-1,1]);
ylabel(
x_a(t)
);title(
Ts=0.01
);
Ts2=0.05;Fs=1/Ts2;
xa2=spline(Ts2*n2,xn2,t);
subplot(3,1,2);plot(t,xa2);axis([0,1,-1,1]);
ylabel(
x_a(t)
);title(
Ts=0.05
);
Ts3=0.1;Fs=1/Ts3;
xa3=spline(Ts3*n3,xn3,t);
subplot(3,1,3);plot(t,xa3);axis([0,1,-1,1]);
ylabel(
x_a(t)
);title(
Ts=0.1
);
结果分析与体会:采用内插从样本重建模拟信号时,0.01s和0.05s依据奈奎斯特采样定理应该能恢复原来的波形,但因为采样点太少,间距分散导致0.05s时无法恢复。
题目二
滤波器设计
设计内容:
一个混合正弦信号包含5Hz、15Hz、30Hz的3中频率信号,现要求分别设计滤波器,保留15Hz频率分量信号,给定采样频率100Hz。
(1)设计IIR型滤波器,分别用巴特沃斯型,切比雪夫型和椭圆型来实现。
(2)设计FIR型滤波器,分别用窗函数法、频率采样法和等波纹逼近法来设计FIR滤波器。
设计思考题:
1.不同方法设计的滤波器滤波性能的异同?
2.窗函数对滤波特性的影响,最优化设计中常用的逼近准则有哪些?
(1)
clear;close
all;clc
fs=100;
t=0:1/fs:1;
f1=5;
f2=15;
f3=30;
ys=sin(2*pi*f1*t)+sin(2*pi*f2*t)+sin(2*pi*f3*t);
subplot(311);
plot(t,ys);
wp
=
[11,18]*2/fs;
ws
=
[8,22]*2/fs;
Rp=2;Rs=50;
%设计模拟滤波器
[N,wc]=buttord(wp,ws,Rp,Rs);%求出滤波器阶数和2dB截止频率
[B,A]=butter(N,wc);%求零极点
yf
=
filter(B,A,ys)
subplot(312);
plot(t,yf);
grid
on
[h,f]=freqz(B,A,1024,fs);%求数字滤波器频率响应
subplot(313)
plot(f,20*log10(abs(h)));axis([0
50
-600
100]);
grid;
xlabel(
频率/Hz
);ylabel(
幅度/dB
);
title(
巴特沃斯滤波器
);
(2)
clear;close
all;clc
fs=100;
t=0:1/fs:1;
f1=5;
f2=15;
f3=30;
ys=sin(2*pi*f1*t)+sin(2*pi*f2*t)+sin(2*pi*f3*t);
subplot(311);
plot(t,ys);
wp
=
[11,18]*2/fs;
ws
=
[8,22]*2/fs;
Rp=2;Rs=50;
[N,wc]=cheb1ord(wp,ws,Rp,Rs);
[B,A]=cheby1(N,Rp,wc);%切比雪夫I型
yf=filter(B,A,ys)
subplot(312)
plot(t,yf);
grid
on;
[h,f]=freqz(B,A,1024,fs);
subplot(313)
plot(f,20*log10(abs(h)));
grid;
xlabel(
频率/Hz
);ylabel(
幅度/dB
);
title(
切比雪夫滤波器
);
(3)
clear;close
all;clc
fs=100;
t=0:1/fs:1;
f1=5;f2=15;f3=30;
ys=sin(2*pi*f1*t)+sin(2*pi*f2*t)+sin(2*pi*f3*t);
subplot(311);
plot(t,ys);
wp
=
[11,18]*2/fs;
ws
=
[8,22]*2/fs;
Rp=2;Rs=50;
[N,wc]=ellipord(wp,ws,Rp,Rs);
[B,A]=ellip(N,Rp,Rs,wc);
yf=filter(B,A,ys)
subplot(312)
plot(t,yf);
grid
on;
[h,f]=freqz(B,A,1024,fs);
subplot(313)
plot(f,20*log10(abs(h)));
grid;
xlabel(
频率/Hz
);ylabel(
幅度/dB
);
title(
椭圆型滤波器
);
第二问
(1)
clear;close
all;clc
fs=100;t=0:1/fs:1;
f1=5;
f2=15;
f3=30;
ys
=
sin(2*pi*f1*t)+sin(2*pi*f2*t)+sin(2*pi*f3*t);
figure;subplot(211);
plot(t,ys);
axis([0
1
-3
3]);
grid
on
title(
混合正弦信号图
);
n
=
36;
Wn
=
[10,20]*2/fs;
b
=
fir1(n,Wn);
yf
=
filter(b,1,ys)
subplot(212)
plot(t,yf);
title(
哈明窗滤波后15Hz正弦信号图
);
grid
on
axis([0
1
-2
2]);
figure;freqz(b,1,512)
title(
哈明窗带通滤波器
);
(2)
clear;close
all;clc
fs=100;t=0:0.01:pi/5;
y=sin(2*pi*5*t)+sin(2*pi*15*t)+sin(2*pi*30*t);
fs1=8;fp1=11;fp2=18;fs2=22;
ws1=fs1*2*pi/fs;wp1=fp1*2*pi/fs;
wp2=fp2*2*pi/fs;ws2=fs2*2*pi/fs;
m=1;n=41;N=(n-1)/2;
n1=fix(wp1/(2*pi/n));
n2=fix(wp2/(2*pi/n));
n3=n2-n1;
n4=n-n2;
t1=0.1;
Hk=[zeros(1,n1),t1,ones(1,n3),t1,zeros(1,n4-2)];
k1=0:floor((n-1)/2);k2=floor((n-1)/2)+1:n-1;
angH=[-
N*(2*pi)/n*k1,N*(2*pi/n*(n-k2))];
H=Hk.*exp(j*angH);
hn=real(ifft(H));
figure;freqz(hn);
axis([0
1
-100
0]);
title(
频率采样带通滤波器
);
y2=filter(hn,1,y);
figure;subplot(2,1,2);plot(t,y2);
title(
频率采样滤波后15Hz正弦信号图
);xlabel(
t
);ylabel(
yt1
);grid
on;
subplot(2,1,1);plot(t,y);
title(
混合正弦信号图
);xlabel(
t
);ylabel(
yt
);grid
on;
(3)
clear;close
all;clc
fs=100;t=0:0.01:pi/5;
y=sin(2*pi*5*t)+sin(2*pi*15*t)+sin(2*pi*30*t);
fs1=8;fp1=11;fp2=18;fs2=22;
ws1=fs1*2/fs;wp1=fp1*2/fs;
wp2=fp2*2/fs;ws2=fs2*2/fs;
f=[ws1,wp1,wp2,ws2];
m=[0,1,0];
Ap=1;As=40;
dat1=(10^(Ap/20)-1)/(10^(Ap/20)+1);dat2=10^(-As/20);
rip=[dat2,dat1,dat2];
[M,fo,mo,w]=remezord(f,m,rip);
M=M+1;
hn=remez(M,fo,mo,w);
y2=filter(hn,1,y);
figure;subplot(2,1,1);plot(t,y);
title(
混合正弦信号图
);xlabel(
t
);ylabel(
yt
);grid
on;
subplot(2,1,2);plot(t,y2);
title(
等波纹逼近滤波后15Hz正弦信号图
);xlabel(
t
);ylabel(
yt1
);grid
on;
figure;freqz(hn);title(
等波纹逼近带通滤波器
);
题目三:语音信号滤波处理
设计内容:
1.利用Windows下的录音机录制一段带有噪声的话音,时间在1s内。然后在Matlab软件平台下,利用wavread函数对语音信号进行采样,记住采样频率和采样点数;
2.画出语音信号的时域波形,对采样后的语音信号进行傅立叶变换,得到信号的频谱特性,画出频谱图;
3.根据对语音信号谱分析的结果,确定滤除噪声所需滤波器的技术指标,设计合适的数字滤波器,并画出滤波器的频域响应;
4.用所设计的滤波器对采集的信号进行滤波,画出滤波前后信号的时域波形和频谱;
5.回放语音信号;sound(x)
设计思考题:
(1)语音信号频率的范围?
(2)滤波前后信号有什么变化?
%语音信号的时域和频域波形
[y,fs,bits]=wavread(
Yangxue.wav
);
sound(y,fs,bits);
[a,b]=size(y);
Y=fftshift(fft(y(500:1000)));
subplot(211);plot(y);
title(
原始信号波形
);
k=0:500;
f=(k/500)*fs;
subplot(212);plot(f,abs(Y));
title(
原始信号频谱
);
%语音信号的时域和频域波形
[y,fs,bits]=wavread(
Yangxue.wav
);
sound(y,fs,bits);
[a,b]=size(y);
Y=fftshift(fft(y(500:1000)));
subplot(211);plot(y(500:1000));
title(
原始信号波形
);
k=0:500;
f=(k/500)*fs;
subplot(212);plot(f,abs(Y));
title(
原始信号频谱
);
%用双线性变换法设计IIR低通滤波器
fp=1000;fc=1200;As=100;Ap=1;
fs=22050;
wc=2*fc/fs;
wp=2*fp/fs;
[n,wn]=ellipord(wp,wc,Ap,As);
[b,a]=ellip(n,Ap,As,wn);
freqz(b,a,512,fs);
[y,fs,bits]=wavread(
Yangxue.wav
);
sound(y,fs,bits);
[a,b]=size(y);
Y=fftshift(fft(y(500:1000)));
subplot(211);plot(y(500:1000));
k=0:500;
f=(k/500)*fs;
title(
原始信号波形
);axis([0,499,-1,1]);
subplot(212);plot(f,abs(Y));
title(
原始信号频谱
);axis([0,499,0,19]);
%用双线性变换法设计IIR低通滤波器
fp=1000;fc=1200;As=100;Ap=1;
fs=22050;
wc=2*fc/fs;
wp=2*fp/fs;
[n,wn]=ellipord(wp,wc,Ap,As);
[b,a]=ellip(n,Ap,As,wn);
freqz(b,a,512,fs);
%对原始语音信号滤波后的时域与频域波形
y1=y(500:1000);
x=filter(b,a,y1);
X=fftshift(fft(x));
subplot(211);plot(x);title(
滤波后信号波形
);axis([0
499
-1
1]);
subplot(212);plot(abs(X));title(
滤波后信号频谱
);axis([0
499
0
19]);
题目四:雷达信号的仿真
设计原理:
雷达系统中常用的雷达信号是线性调频信号,,其中k为调频率。假设信号的持续时间为,信号带宽为,则调频率为。
在matlab中表示线性调频信号,必须对s(t)进行采样。
设计内容:
(1)产生线性调频信号,信号的持续时间,信号带宽,其采样率,并给出其频率特性。
(2)在(1)的基础上,将采样频率变为,其余特性不变,产生线性调频信号及其给出其频率特性并与(1)所比较。
(3)将(1)所产生的线性调频信号通过一个匹配滤波器,给出输出结果。
(4)在信噪比两种情况下,给出匹配滤波器的相应结果。
(1)
T=25e-6;
B=30e6;
K=B/T;
Fs=2*B;Ts=1/Fs;
N=T/Ts;
t=linspace(-T/2,T/2,N);
St=exp(j*pi*K*t.^2);
subplot(211)
plot(t*1e6,St);
xlabel(
Time
in
u
sec
);
title(
采样频率2B时线性调频信号
);
grid
on;axis
tight;
subplot(212)
freq=linspace(-Fs/2,Fs/2,N);
plot(freq*1e-6,fftshift(abs(fft(St))));
xlabel(
Frequency
in
MHz
);
title(
线性调频信号的幅频特性
);
grid
on;axis
tight;
(2)
T=25e-6;
B=30e6;
K=B/T;
Fs=1.5*B;Ts=1/Fs;
N=T/Ts;
t=linspace(-T/2,T/2,N);
St=exp(j*pi*K*t.^2);
subplot(211)
plot(t*1e6,St);
xlabel(
Time
in
u
sec
);
title(
采样频率1.5B时线性调频信号
);
grid
on;axis
tight;
subplot(212)
freq=linspace(-Fs/2,Fs/2,N);
plot(freq*1e-6,fftshift(abs(fft(St))));
xlabel(
Frequency
in
MHz
);
title(
线性调频信号的幅频特性
);
grid
on;axis
tight;
