数字信号处理 MATLAB程序

更新时间:2023-08-09 17:15:01 阅读量: IT计算机 文档下载

说明:文章内容仅供预览,部分内容可能不全。下载后的文档,内容与下面显示的完全一致。下载之前请确认下面内容是否您想要的,是否完整无缺。

例题3.1.1

Fm=10;Fc=100;Fs=500; k=0:199; t=k/Fs;

x=sin(2*pi*Fm*t); y=x.*cos(2*pi*Fc*t); Y=fft(y,256); subplot(2,1,1);plot(y);

subplot(2,1,2);plot([-128:127],fftshift(abs(Y))); 实验所得的图像如下图所示:

实验内容

1.实现抑制载波的幅度调制。已调信号y(t) x(t)cos( ct),式中x(t)为调制信号;

cos( ct)rad/s

为载波信号。此处可取x(t) cos( m t), c 80 rad/s, m 10

(1)分析调制信号x(t)的频谱,绘出其时域波形和频谱。 Matlab程序如下: Fs=1000; Fc=40; N=1000;

wc=80*pi; n=0:N-2; t=n/Fs;

x=cos(10*pi*pi*t); y=x.*cos(wc*t); z1=fft(x,256);

subplot(2,1,1);plot(t,x);legend('x(t)的时域波形');

subplot(2,1,2);plot([-128:127],fftshift(abs(z1)));legend('x(t)的频谱'); 实验所得图形如下:

(2)分析已调信号y(t)的频谱,绘出其时域波形和频谱。 Matlab程序如下: Fs=1000; Fc=40; N=1000; n=0:N-2; t=n/Fs;

x=cos(10*pi*pi*t);

y=modulate(x,Fc,Fs,'am'); z=fft(y,256);

subplot(2,1,1);plot(t,y);legend('y(t)的时域波形');

subplot(2,1,2);plot([-128:127],fftshift(abs(z)));legend('y(t)的频域波形

')

(3)设计低通滤波器并应用filter函数,实现信号同步解调 设计的低通滤波器为cheby1型低通滤波器,技术参数为: wp=0.2*pi,ws=0.6*pi,Ap=1Db,As=25dB 调制:

[N,wc]=cheb1ord(0.2*pi,0.6*pi,1,25,’s’); [num,den]=cheby1(N,1,wc,’s’); [b,a]=bilinear(num,den,0.5); x=cos(10*pi*pi*t); y=x.*cos(80*pi*t); w1=filter(b,a,y); plot(w1); Y=fft(w1);

plot(w1);axis([0 500 -1 1]);

调制后的波形如下图:

解调:

[N,wc]=cheb1ord(0.2*pi,0.6*pi,1,25,'s'); [num,den]=cheby1(N,1,wc,'s'); [b,a]=bilinear(num,den,0.5); x=cos(10*pi*pi*t); y=x.*cos(80*pi*t); w1=filter(b,a,y); plot(w1); Y=fft(w1);

Q=demod(Y,Fc,Fs,'am'); plot(t,Q);

axis([0.3 0.5 -0.1 0.1]); 解调后的波形如下图:

2.实现含有载波的幅度调制。已调信号y(t) [A mx(t)]cos( ct),A 1,m 0.5,观察调制结果,与抑制载波的幅度调制有什么不同?

Matlab程序:

Fm=10;Fc=100;Fs=1000;N=1000; k=0:N-1; t=k/Fs;

x=sin(2*pi*Fm*t); subplot(3,1,1); plot(t,x); xlabel('t(s)');

title('Modulate signal'); y=modulate(x,Fc,Fs,'am'); subplot(3,1,2); plot(t,y); xlabel('t(s)');

选取

title('Modulateed signal(AM)'); y1=(1+0.5*x).*sin(100*pi*t); subplot(3,1,3); plot(t,y1); xlabel('t(s)');

title('Modulateed signal'); 两种调制结果如下:

(3)实现含有载波的幅度调制y(t) [A mx(t)]cos( ct),调制信号为

t

t

t04t04

t

3t04

t04 t

3t04

x(t) t t0

t

3t4

t04

设t0 5s,载波为cos( ct) cos(100 t),取A 1,m 0.8。 (1)分析调制信号x(t)的频谱,绘出其时域波形和频谱。 (2)分析已调信号y(t)的频谱,绘出其时域波形和频谱。 ①Matlab程序为: Fs=1000; Fc=40; N=1000; wc=80*pi; n=0:N-2;

t=0.5/4:0.001:1.5/4; x=t;

z1=fft(x,256);subplot(4,1,1);plot(t,x); grid on;legend('x(t)= t的时域波形');

subplot(4,1,2);plot([-128:127],fftshift(abs(z1))); grid on;legend('x(t)= t时的频谱'); y=(1+0.8*x).*cos(100*pi*t); z=fft(y,256);

subplot(4,1,3);plot(t,y);

grid on;legend('y(t)的时域波形');

subplot(4,1,4);plot([-128:127],fftshift(abs(z))); grid on;legend('y(t)的频域波形'); 实验图形如下图所示:

②Matlab程序为: Fs=1000; Fc=40; N=1000; wc=80*pi; n=0:N-2;

t=0.5/4:0.001:1.5/4; t0=0.5; x=-t+t0/4;

z1=fft(x,256);subplot(4,1,1);plot(t,x); grid on;legend('x(t)= -t+t0/4的时域波形');

subplot(4,1,2);plot([-128:127],fftshift(abs(z1))); grid on;legend('x(t)= -t+t0/4时的频谱'); y=(1+0.8*x).*cos(100*pi*t); z=fft(y,256);

subplot(4,1,3);plot(t,y);

grid on;legend('y(t)的时域波形');

subplot(4,1,4);plot([-128:127],fftshift(abs(z))); grid on;legend('y(t)的频域波形'); 实验图形如下图所示:

③Matlab程序为: Fs=1000; Fc=40; N=1000; wc=80*pi; n=0:N-2;

t=0.5/4:0.001:1.5/4; t0=0.5; x=t-t0; z1=fft(x,256); subplot(4,1,1);plot(t,x);

grid on;legend('x(t)=t-t0的时域波形'); subplot(4,1,2);plot([-128:127],fftshift(abs(z1))); grid on;legend('x(t)=t-t0时的频谱'); y=(1+0.8*x).*cos(100*pi*t); z=fft(y,256);

subplot(4,1,3);plot(t,y);

grid on;legend('y(t)的时域波形');

subplot(4,1,4);plot([-128:127],fftshift(abs(z))); grid on;legend('y(t)的频域波形');

实验图形如下图所示:

(3)若传输中有噪声加入。生成噪声信号0.1*randn(1,N),叠加在已调信号y(t)上,观察其时域波形和频谱。 wc=80*pi; t=0.5/4:0.001:1.5/4; N=length(t); x1=t;

y1=(1+0.8*x1).*cos(100*pi*t)+0.1*randn(1,N); z1=fft(y1,256); subplot(3,2,1);plot(t,y1);

grid on; legend('x(t)= t的时域波形');

subplot(3,2,2);plot([-128:127],fftshift(abs(z1)));

grid on; legend('x(t)= t的频域波形'); x2=-t+t0/4;

y2=(1+0.8*x2).*cos(100*pi*t)+0.1*randn(1,N); z2=fft(y2,256); subplot(3,2,3);plot(t,y1);

grid on; legend('x(t)= -t+t0/4的时域波形'); subplot(3,2,4);plot([-128:127],fftshift(abs(z2))); grid on; legend('x(t)= -t+t0/4的频域波形'); x3=t-t0;

y3=(1+0.8*x3).*cos(100*pi*t)+0.1*randn(1,N); z3=fft(y3,256); subplot(3,2,5);plot(t,y3);

grid on; legend('x(t)= t-t0的时域波形'); subplot(3,2,6);plot([-128:127],fftshift(abs(z3))); grid on; legend('x(t)= t-t0的频域波形');

实验图形如下图所示:

4.实现频分复用(FDMA)。已知三个已调制信号aip[k],经幅度调制而产生的

3

FDMA信号为s[k]

i 1

aip[k] cos(

ki

4

)

式中:ai为常数;p[k]为具有窄带特性的Hanning信号,其定义为

0.5 )0 k N 1 0.5

N 12 k

p[k]

0 其他

若将此已调信号通过信道传输,描述该信道的模型为宜全通系统,其差分方程为

y[k] 1.1172y[k 1] 0.9841y[k 2] 0.4022y[k 3] 0.2247y[k 44] 0.2247x[k] 0.4022x[k 1] 0.9841x[k 2] 1.1172x[k 3] x[k 3]

已调信号s(k)通过该信道后,得到的接收信号为y(k) s(k)*h(k)。 1

N=75; k=0:N-1; n=length(k);

p=0.5-0.5*cos(2*pi*k./(N-1)); z1=fft(p,n);

subplot(2,1,1);plot(k,p);grid on;legend('p(k)的时域波形');

subplot(2,1,2);plot(k,fftshift(abs(z1)));grid on;legend('p(k)的频谱

');

2

N=75; k=0:N-1;

n=length(k);

p=0.5-0.5*cos(2*pi*k./(N-1));

s=p.*(cos(pi*k/4)+2*cos(pi*k/2)+3*cos(3*pi*k/4)); z2=fft(s,n);

subplot(2,1,1);plot(k,s);grid on;legend('s(k)的时域波形');

subplot(2,1,2);plot(k,fftshift(abs(z2)));grid on;legend('s(k)的频谱

');

3

频率响应特性

a=[1 -1.1172 0.9842 -0.4022 0.2247]; b=[0.2247 -0.4022 0.9842 -1.1172 1]; w=linspace(1,pi,512);

H=freqz(a,b,w);plot(w/pi,abs(H));

单位脉冲响应

a=[1 -1.1172 0.9842 -0.4022 0.2247]; b=[0.2247 -0.4022 0.9842 -1.1172 1]; n=-0.1:0.01:0.5; x=impDT(n); y=filter(b,a,x); plot(n,y);grid on;

4

a=[1 -1.1172 0.9842 -0.4022 0.2247]; b=[0.2247 -0.4022 0.9842 -1.1172 1]; k=0:0.1:100;

p=0.5-0.5*cos(2*pi*k./74);

s=p.*(cos(pi*k/4)+2*cos(pi*k/2)+3*cos(3*pi*k/4)); y=filter(b,a,s); z1=fft(y,256);

plot([-128:127],fftshift(abs(z1)));axis([-30 30 0 120]);grid on;

本文来源:https://www.bwwdw.com/article/mfnj.html

Top