数字信号处理实验报告
数字信号处理实验报告 3

数字信号处理实验报告姓名:班级:通信学号:实验名称:频域抽样定理验证实验类型:验证试验指导教师:实习日期:2013.频域采样定理验证实验一. 实验目的:1. 加深对离散序列频域抽样定理的理解2.了解由频谱通过IFFT 计算连续时间信号的方法3.掌握用MATLAB 语言进行频域抽样与恢复时程序的编写方法 4、用MATLAB 语言将X(k)恢复为X(z)及X(e jw )。
二. 实验原理:1、1、频域采样定理: 如果序列x(n)的长度为M ,频域抽样点数为N ,则只有当频域采样点数N ≥M 时,才有x N (n)=IDFT[X(k)]=x(n),即可由频域采样X(k)无失真的恢复原序列 x(n)。
2、用X(k)表示X(z)的内插公式:∑-=-----=10111)(1)(N k kNNzWz k X Nz X内插函数: zWzkNNN z 1k111)(-----=ϕ频域内插公式:∑-=-=10)2()()(N K j k Nk X e X πωϕω频域内插函数:e N j N N )21()2sin()2sin(1)(--=ωωωωϕ三. 实验任务与步骤:实验一:长度为26的三角形序列x(n)如图(b)所示,编写MATLAB 程序验证频域抽样定理。
实验二:已知一个时间序列的频谱为X(e jw )=2+4e -jw +6e -j2w +4e -j3w +2e -j4w分别取频域抽样点数N为3、5和10,用IPPT计算并求出其时间序列x(n),用图形显示各时间序列。
由此讨论原时域信号不失真地由频域抽样恢复的条件。
实验三:由X32(k)恢复X(z)和X(e jw)。
四.实验结论与分析:实验一:源程序:M=26;N=32;n=0:M; %产生M长三角波序列x(n)xa=0:floor(M/2);xb= ceil(M/2)-1:-1:0; xn=[xa,xb];Xk=fft(xn,512); %1024点FFT[x(n)], 用于近似序列x(n)的TFX32k=fft(xn,32); %32点FFT[x(n)]x32n=ifft(X32k); %32点IFFT[X32(k)]得到x32(n)X16k=X32k(1:2:N); %隔点抽取X32k得到X16(K)x16n=ifft(X16k,N/2); %16点IFFT[X16(k)]得到x16(n)subplot(3,2,2);stem(n,xn,'.');box ontitle('(b) 三角波序列x(n)');xlabel('n');ylabel('x(n)');axis([0,32,0,20])k=0:511;wk=2*k/512;subplot(3,2,1);plot(wk,abs(Xk));title('(a)FT[x(n)]');xlabel('\omega/\pi');ylabel('|X(e^j^\omega)|');axis([0,1,0,200])k=0:N/2-1;subplot(3,2,3);stem(k,abs(X16k),'.');box ontitle('(c) 16点频域');xlabel('k');ylabel('|X_1_6(k)|');axis([0,8,0,200])n1=0:N/2-1;subplot(3,2,4);stem(n1,x16n,'.');box ontitle('(d) 16点IDFT[X_1_6(k)]');xlabel('n');ylabel('x_1_6(n)');axis([0,32,0,20])k=0:N-1;subplot(3,2,5);stem(k,abs(X32k),'.');box ontitle('(e) 32点频域采样');xlabel('k');ylabel('|X_3_2(k)|');axis([0,16,0,200])n1=0:N-1;subplot(3,2,6);stem(n1,x32n,'.');box ontitle('(f) 32点IDFT[X_3_2(k)]');xlabel('n');ylabel('x_3_2(n)');axis([0,32,0,20])结果如下所示:实验一分析:序列x(n)的长度M=26,由图中可以看出,当采样点数N=16<M时,x16(n)确实等于原三角序列x(n)以16为周期的周期延拓序列的主值序列。
数字信号处理实验报告

实验一 信号、系统及系统响应一、实验目的1、熟悉理想采样的性质,了解信号采样前后的频谱变化,加深对时域采样定理的理解。
2、熟悉离散信号和系统的时域特性。
3、熟悉线性卷积的计算编程方法:利用卷积的方法,观察、分析系统响应的时域特性。
4、掌握序列傅里叶变换的计算机实现方法,利用序列的傅里叶变换对离散信号、系统及其系统响应进行频域分析。
二、 实验原理1.理想采样序列:对信号x a (t)=A e −αt sin(Ω0t )u(t)进行理想采样,可以得到一个理想的采样信号序列x a (t)=A e −αt sin(Ω0nT ),0≤n ≤50,其中A 为幅度因子,α是衰减因子,Ω0是频率,T 是采样周期。
2.对一个连续时间信号x a (t)进行理想采样可以表示为该信号与一个周期冲激脉冲的乘积,即x ̂a (t)= x a (t)M(t),其中x ̂a (t)是连续信号x a (t)的理想采样;M(t)是周期冲激M(t)=∑δ+∞−∞(t-nT)=1T ∑e jm Ωs t +∞−∞,其中T 为采样周期,Ωs =2π/T 是采样角频率。
信号理想采样的傅里叶变换为X ̂a (j Ω)=1T ∑X a +∞−∞[j(Ω−k Ωs )],由此式可知:信号理想采样后的频谱是原信号频谱的周期延拓,其延拓周期为Ωs =2π/T 。
根据时域采样定理,如果原信号是带限信号,且采样频率高于原信号最高频率分量的2倍,则采样以后不会发生频率混叠现象。
三、简明步骤产生理想采样信号序列x a (n),使A=444.128,α=50√2π,Ω0=50√2π。
(1) 首先选用采样频率为1000HZ ,T=1/1000,观察所得理想采样信号的幅频特性,在折叠频率以内和给定的理想幅频特性无明显差异,并做记录;(2) 改变采样频率为300HZ ,T=1/300,观察所得到的频谱特性曲线的变化,并做记录;(3) 进一步减小采样频率为200HZ ,T=1/200,观察频谱混淆现象是否明显存在,说明原因,并记录这时候的幅频特性曲线。
数字信号实验报告材料 (全)

数字信号处理实验报告实验一:用 FFT 做谱分析 一、 实验目的1、进一步加深 DFT 算法原理和基本性质的理解。
2、熟悉 FFT 算法原理和 FFT 子程序的应用。
3、学习用FFT 对连续信号和时域离散信号进行谱分析的方法,了解可能出现的分析误差及其原因,以便在实际中正确应用 FFT 。
二、实验原理用FFT 对信号作频谱分析是学习数字信号处理的重要内容。
经常需要进行谱分析的信号是模拟信号和时域离散信号。
对信号进行谱分析的重要问题是频谱分辨率D 和分析误差。
频谱分辨率直接和FFT 的变换区间N 有关,因为FFT 能够实现的频率分辨率是2π/N ≤D 。
可以根据此时选择FFT 的变换区间N 。
误差主要来自于用FFT 作频谱分析时,得到的是离散谱,而信号(周期信号除外)是连续谱,只有当N 较大时离散谱的包络才能逼近于连续谱,因此N 要适当选择大一些。
周期信号的频谱是离散谱,只有用整数倍周期的长度作FFT ,得到的离散谱才能代表周期信号的频谱。
如果不知道信号周期,可以尽量选择信号的观察时间长一些。
对模拟信号的频谱时,首先要按照采样定理将其变成时域离散信号。
如果是模拟周期信号,也应该选取整数倍周期的长度,经过采样后形成周期序列,按照周期序列的谱分析进行。
三、实验内容和步骤对以下典型信号进行谱分析:⎪⎩⎪⎨⎧≤≤-≤≤-=⎪⎩⎪⎨⎧≤≤-≤≤+==其它nn n n n n x 其它nn n n n n x n R n x ,074,330,4)(,074,830,1)()()(32414()cos4x n n π=5()cos(/4)cos(/8)x n n n ππ=+6()cos8cos16cos20x t t t t πππ=++对于以上信号,x1(n)~x5(n) 选择FFT 的变换区间N 为8和16 两种情况进行频谱分析。
分别打印其幅频特性曲线。
并进行对比、分析和讨论;;x6(t)为模拟周期信号,选择 采样频率Hz F s 64=,变换区间N=16,32,64 三种情况进行谱分析。
数字信号处理实验六报告

实验六 频域抽样定理和音频信号的处理实验报告 (一)频域抽样定理给定信号1, 013()27, 14260, n n x n n n +≤≤⎧⎪=-≤≤⎨⎪⎩其它 1.利用DTFT 计算信号的频谱()j X e ω,一个周期内角频率离散为M=1024点,画出频谱图,标明坐标轴。
n=0:100; %设定n 及其取值范围for n1=0:13 %对于n 处于不同的取值范围将n 代入不同的表达式xn(n1+1)=n1+1;endfor n2=14:26xn(n2+1)=27-n2;endfor n3=27:100xn(n3+1)=0;endM=1024; %设定抽样离散点的个数k=0:M-1; %设定k 的取值范围w=2*pi*k/M; %定义数字角频率[X,w] = dtft2( xn,n, M ) %调用dtft2子程序求频谱plot(w,abs(X)); %画出幅度值的连续图像xlabel('w/rad');ylabel('|X(exp(jw))|');title(' M=1024时的信号频谱图像'); %标明图像的横纵坐标和图像标题function [X,w] = dtft2(xn, n, M ) %定义x(n)的DTFT 函数w=0:2*pi/M:2*pi-2*pi/M; %将数字角频率w 离散化L=length(n); %设定L 为序列n 的长度 for (k=1:M) %外层循环,w 循环M 次sum=0; %每确定一个w 值,将sum 赋初值为零for (m=1:L) %内层循环,对n 求和,循环次数为n 的长度sum=sum+xn(m)*exp(-j*w(k)*n(m)); %求和X(k)=sum; %把每一次各x(n)的和的总值赋给X ,然后开始对下一个w 的求和过程end %内层循环结束end%外层循环结束M=1024时的信号频谱图像如图1-1所示:图1-1 M=1024时的信号频谱图像2.分别对信号的频谱()jX eω在区间π[0,2]上等间隔抽样16点和32点,得到32()X k和16()X k。
数字信号处理实验报告

数字信号处理实验报告实验一:频谱分析与采样定理一、实验目的1.观察模拟信号经理想采样后的频谱变化关系。
2.验证采样定理,观察欠采样时产生的频谱混叠现象3.加深对DFT算法原理和基本性质的理解4.熟悉FFT算法原理和FFT的应用二、实验原理根据采样定理,对给定信号确定采样频率,观察信号的频谱三、实验内容和步骤实验内容(1)在给定信号为:1.x(t)=cos(100*π*at)2.x(t)=exp(-at)3.x(t)=exp(-at)cos(100*π*at)其中a为实验者的学号,用DFT分析上述各信号的频谱结构,选取不同的采样频率和截取长度,试分析频谱发生的变化。
实验内容(2)设x(n)=cos(0.48*π*n)+ cos(0.52*π*n),对其进行以下频谱分析:10点DFT,64点DFT,及在10点序列后补零至64点的DFT 试分析这三种频谱的特点。
四、实验步骤1.复习采样理论、DFT的定义、性质和用DFT作谱分析的有关内容。
2.复习FFT算法原理和基本思想。
3.确定实验给定信号的采样频率,编制对采样后信号进行频谱分析的程序五、实验程序和结果实验1内容(1)N=L/T+1;t=0:T:L;a=48;D1=2*pi/(N*T); % 求出频率分辨率k1=floor((-(N-1)/2):((N-1)/2)); % 求对称于零频率的FFT位置向量%%%%%%%%%%%%%%%%%%%%%%%%%figure(1),x1=cos(100*pi*a*t);y1=T*fftshift(fft(x1));%虽然原来是周期信号,但做了截断后,仍可当作非周期信号。
subplot(2,1,1),plot(t,x1);title('正弦信号');subplot(2,1,2),plot(k1*D1,abs(y1));title('正弦信号频谱'); %%%%%%%%%%%%%%%%%%%%% figure(2), x2=exp(-a*t);y2=T*fftshift(fft(x2));%有限长(长度为N)离散时间信号x1的dft 再乘T 来近似模拟信号的频谱,长度为Nsubplot(2,1,1),plot(t,x2);title('指数信号');subplot(2,1,2),plot(k1*D1,abs(y2));title('指数信号频谱'); %%%%%%%%%%%%%%%%%%%%% figure(3), x3=x1.*x2;y3=T*fftshift(fft(x3))subplot(2,1,1),plot(t,x3);title('两信号相乘');subplot(2,1,2),plot(k1*D1,abs(y3));title('两信号相乘频谱');0.020.040.060.080.10.120.140.16-1-0.500.51正弦信号-4000-3000-2000-10000100020003000400000.020.040.06正弦信号频谱00.020.040.060.080.10.120.140.160.51-4000-3000-2000-10000100020003000400000.010.020.03指数信号频谱0.020.040.060.080.10.120.140.16-1-0.500.51两信号相乘-4000-3000-2000-10000100020003000400000.0050.010.015两信号相乘频谱T=0.0005 L=0.150.020.040.060.080.10.120.140.16-1-0.500.51-8000-6000-4000-2000200040006000800000.020.040.060.08正弦信号频谱00.020.040.060.080.10.120.140.160.51指数信号-8000-6000-4000-20000200040006000800000.010.020.03指数信号频谱0.020.040.060.080.10.120.140.16-1-0.500.51-8000-6000-4000-20000200040006000800000.0050.010.015两信号相乘频谱T=0.002 L=0.150.020.040.060.080.10.120.140.16-1-0.500.51正弦信号-2000-1500-1000-50050010001500200000.020.040.060.08正弦信号频谱00.020.040.060.080.10.120.140.160.51-2000-1500-1000-500050010001500200000.010.020.03指数信号频谱0.020.040.060.080.10.120.140.16-1-0.500.51两信号相乘-2000-1500-1000-500050010001500200000.0050.010.015两信号相乘频谱T=0.001 L=0.180.020.040.060.080.10.120.140.160.18-1-0.500.51-4000-3000-2000-1000100020003000400000.020.040.060.08正弦信号频谱00.020.040.060.080.10.120.140.160.180.51指数信号-4000-3000-2000-10000100020003000400000.010.020.03指数信号频谱0.020.040.060.080.10.120.140.160.18-1-0.500.51-4000-3000-2000-10000100020003000400000.0050.010.015两信号相乘频谱T=0.001 L=0.120.020.040.060.080.10.12-1-0.500.51正弦信号-4000-3000-2000-10000100020003000400000.020.040.06正弦信号频谱00.020.040.060.080.10.120.51-4000-3000-2000-10000100020003000400000.010.020.03指数信号频谱0.020.040.060.080.10.12-1-0.500.51两信号相乘-4000-3000-2000-10000100020003000400000.0050.010.015两信号相乘频谱实验1内容(2)>> N=10;n=1:NT=1x1=cos(0.48*pi*n*T)+cos(0.52*pi*n*T)X1=fft(x1,10)k=1:N;w=2*pi*k/10subplot(3,2,1);stem(n,x1);axis([0,10,-3,3]);title('信号x(n)');subplot(3,2,2);stem(w/pi,abs(X1));axis([0,1,0,10]);title('DFTx(n)');%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% N2=100;n2=1:N2T=1x1=cos(0.48*pi*[1:10]*T)+cos(0.52*pi*[1:10]*T)x2=[x1,zeros(1,90)]X2=fft(x2,N2)k2=1:N2;w2=2*pi*k2/100subplot(3,2,3);stem(x2);axis([0,100,-3,3]);title('信号x(n)补零');subplot(3,2,4);plot(w2/pi,abs(X2));axis([0,1,0,10]);title('DFTx(n)');%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% N3=100;n3=1:N3T=1x3=cos(0.48*pi*n3*T)+cos(0.52*pi*n3*T)X3=fft(x3,100)k3=1:N3;w3=2*pi*k3/100subplot(3,2,5);stem(n3,x3);axis([0,100,-3,3]);title('信号x(n)');subplot(3,2,6);stem(w3/pi,abs(X3));axis([0,1,0,10]);title('DFTx(n)');n =1 2 3 4 5 6 7 8 9 10 T =1510-202信号x(n)0.510510DFTx(n)50100信号x(n)补零0.510510DFTx(n)50100信号x(n)DFTx(n)实验二 卷积定理一、实验目的通过本实验,验证卷积定理,掌握利用DFT 和FFT 计算线性卷积的方法。
DSP(数字信号处理)实验报告2

本科学生实验报告学号124090314 姓名何胜金学院物电学院专业、班级12电子实验课程名称数字信号处理(实验)教师及职称杨卫平开课学期第三至第四学年下学期填报时间2015 年 3 月 1 9 日云南师范大学教务处编印2.产生幅度调制信号x[t]=cos(2t)cos(200t),推导其频率特性,确定抽样频率,并会出波形。
程序: clc,clear,close all t=[0:0.01:5];x=cos(2*pi*t).*cos(200*pi*t); plot(t,x);clc,clear,close allt0=0:0.001:0.1;x0=0.5*(cos(202*pi*t0)+cos(198*pi*t0)); plot(t0,x0,'r') hold on fs=202;t=0:1/fs:0.1;x=0.5*(cos(202*pi*t)+cos(198*pi*t)); stem(t,x);3.对连续信号x[t]=cos(4t)进行抽样以得到离散序列,并进行重建。
(1)生成信号x(t),时间为t=0:0.001:4,画出x(t)的波形。
程序clc,clear,close all t0=0:0.001:3; x0=cos(4*pi*t0); plot(t0 ,x0,'r');(2)以faam=10HZ对信号进行抽样,画出在0≤t≤1范围内的抽样序列,x[k],利用抽样内插函数恢复连续时间信号,画出重逢信号的波形。
程序:clc,clear,close all t0=0:0.001:3; x0=cos(4*pi*t0); plot(t0,x0); hold onfs=10;t=0:1/fs:3; x=cos(4*pi*t); stem(t,x);4.若x[k]是对连续信号x(t)=cos(0.5t)以samf=2Hz抽样得到的离散序列,如何通过在抽样点之间内插,恢复原连续时间信号x(t)?程序:clc,clear,close all t=0:0.0001:4; x=cos(0.5*pi*t); plot(t,x); Figure1:clc,clear,close allt=0:0.0001:4; x=cos(0.5*pi*t); subplot(2,1,1); plot(t,x);t0=0:0.5:4;x0=cos(0.5*pi*t0); subplot(2,1,2); stem(t0,x0);5.已知序列x[k]={1,3,2,-5;k=0,1,2,3},分别取N=2,3,4,5对其频谱X(e j)进行抽样,再由频域抽样点恢复时域序列,观察时域序列是否存在混叠,有何规律?k=[0,1,2,3]; x=[1,3,2,-5]; n=100;omega=[0:n-1]*2*pi/n;X0=1+3*exp(-j*omega)+2*exp(-2*j*omega)-5*exp(-3*j*omega); subplot(3,4,1);stem(k,x);title('原序列');subplot(3,4,2);plot(omega./pi,abs(X0));title('序列的频谱 N=100');N=2;omega=[0:N-1]*2*pi/N;X1=1+3*exp(-j*omega)+2*exp(-2*j*omega)-5*exp(-3*j*omega); subplot(3,4,5);stem(omega./pi,abs(X1));title('频域抽样 N=2');rx1=real(ifft(X1)); subplot(3,4,9);stem(rx1);title('时域恢复');N=3;omega=[0:N-1]*2*pi/N;X2=1+3*exp(-j*omega)+2*exp(-2*j*omega)-5*exp(-3*j*omega); subplot(3,4,6);stem(omega./pi,abs(X2));title('频域抽样 N=3');rx2=real(ifft(X2)); subplot(3,4,10);stem(rx2);title('时域恢复');N=4;omega=[0:N-1]*2*pi/N;X3=1+3*exp(-j*omega)+2*exp(-2*j*omega)-5*exp(-3*j*omega); subplot(3,4,7);stem(omega./pi,abs(X3));title('频域抽样 N=4');rx3=real(ifft(X3)); subplot(3,4,11);stem(rx3);title('时域恢复');。
数字信号处理实验报告_五个实验

实验一 信号、系统及系统响应一、 实验目的1、熟悉连续信号经理想采样前后的频谱变化关系,加深对时域采样定理的理解;2、熟悉时域离散系统的时域特性;3、利用卷积方法观察分析系统的时域特性;4、掌握序列傅立叶变换的计算机实现方法,利用序列的傅立叶变换对连续信号、离散信号及系统响应进行频域分析。
二、 实验原理及方法采样是连续信号数字处理的第一个关键环节。
对采样过程的研究不仅可以了解采样前后信号时域和频域特性发生变化以及信号信息不丢失的条件,而且可以加深对傅立叶变换、Z 变换和序列傅立叶变换之间关系式的理解。
对一个连续信号)(t x a 进行理想采样的过程可用下式表示:)()()(^t p t t x x aa其中)(^t x a 为)(t x a 的理想采样,p(t)为周期脉冲,即∑∞-∞=-=m nT t t p )()(δ)(^t x a的傅立叶变换为)]([1)(^s m a m j X T j a X Ω-Ω=Ω∑∞-∞= 上式表明^)(Ωj Xa为)(Ωj Xa的周期延拓。
其延拓周期为采样角频率(T /2π=Ω)。
只有满足采样定理时,才不会发生频率混叠失真。
在实验时可以用序列的傅立叶变换来计算^)(Ωj X a 。
公式如下:Tw jwae X j X Ω==Ω|)()(^离散信号和系统在时域均可用序列来表示。
为了在实验中观察分析各种序列的频域特性,通常对)(jw e X 在[0,2π]上进行M 点采样来观察分析。
对长度为N 的有限长序列x(n),有:n jw N n jw k ke m x eX--=∑=)()(1其中,k Mk πω2=,k=0,1,……M-1 时域离散线性非移变系统的输入/输出关系为∑∞-∞=-==m m n h m x n h n x n y )()()(*)()(上述卷积运算也可在频域实现)()()(ωωωj j j e H e X eY =三、 实验程序s=yesinput(Please Select The Step Of Experiment:\n 一.(1时域采样序列分析 s=str2num(s); close all;Xb=impseq(0,0,1); Ha=stepseq(1,1,10);Hb=impseq(0,0,3)+2.5*impseq(1,0,3)+2.2*impseq(2,0,3)+impseq(3,0,3); i=0;while(s);%时域采样序列分析 if(s==1)k=0;while(1)if(k==0)A=yesinput('please input the Amplitude:\n',...444.128,[100,1000]); a=yesinput('please input the Attenuation Coefficient:\n',...222.144,[100,600]);w=yesinput('please input the Angle Frequence(rad/s):\n',...222.144,[100,600]);endk=k+1;fs=yesinput('please input the sample frequence:\n',...1000,[100,1200]);Xa=FF(A,a,w,fs);i=i+1;string+['fs=',num2str(fs)];figure(i)DFT(Xa,50,string);1=yesinput1=str2num(1);end%系统和响应分析else if(s==2)kk=str2num(kk);while(kk)if(kk==1)m=conv(Xb,Hb);N=5;i=i+1;figure(i)string=('hb(n)');Hs=DFT(Hb,4,string);i=i+1;figure(i)string('xb(n)');DFT(Xb,2,string);string=('y(n)=xb(n)*hb(n)');else if (kk==2)m=conv(Ha,Ha);N=19;string=('y(n)=ha(n)*(ha(n)');else if (kk==3)Xc=stepseq(1,1,5);m=conv(Xc,Ha);string=('y(n)=xc(n)*ha(n)');endendendi=i+1;figure(i)DFT(m,N,string);kk=yesinputkk=str2num(kk);end卷积定理的验证else if(s==3)A=1;a=0.5;w=2,0734;fs=1;Xal=FF(A,a,w,fs);i=i+1;figure(i)string=('The xal(n)(A=1,a=0.4,T=1)'); [Xa,w]DFT(Xal,50,string);i=i+1;figure(i)string =('hb(n)');Hs=DFT(Hb,4,string);Ys=Xs.*Hs;y=conv(Xal,Hb);N=53;i=i+1;figure(i)string=('y(n)=xa(n)*hb(n)');[yy,w]=DFT(y,N,string);i=i+1;figure(i)subplot(2,2,1)plot(w/pi,abs(yy));axis([-2 2 0 2]);xlabel('w/pi');ylabel('|Ys(jw)|');title(FT[x(n)*h(n)]');subplot(2,2,3)plot(w/pi,abs(Ys));axis([-2 2 0 2]);xlabel('w/pi');ylabel('|Ys(jw)|');title('FT[xs(n)].FT[h(n)]'); end end end子函数:离散傅立叶变换及X(n),FT[x(n)]的绘图函数 function[c,l]=DFT(x,N,str) n=0:N-1; k=-200:200; w=(pi/100)*k; l=w; c=x*Xc=stepseq(1,1,5); 子函数:产生信号function c=FF(A,a,w,fs) n=o:50-1;c=A*exp((-a)*n/fs).*sin(w*n/fs).*stepseq(0,0,49); 子函数:产生脉冲信号function [x,n]=impseq(n0,n1,n2) n=[n1:n2];x=[(n-n0)==0];子函数:产生矩形框信号function [x,n]=stepseq(n0,n1,n2) n=[n1:n2];x=[(n-n0>=0)];四、 实验内容及步骤1、认真复习采样理论,离散信号与系统,线性卷积,序列的傅立叶变换及性质等有关内容,阅读本实验原理与方法。
数字信号处理实验报告一二

数字信号处理课程实验报告实验一 离散时间信号和系统响应一. 实验目的1. 熟悉连续信号经理想采样前后的频谱变化关系,加深对时域采样定理的理解2. 掌握时域离散系统的时域特性3. 利用卷积方法观察分析系统的时域特性4. 掌握序列傅里叶变换的计算机实现方法,利用序列的傅里叶变换对离散信号及系统响应进行频域分析二、实验原理1. 采样是连续信号数字化处理的第一个关键环节。
对采样过程的研究不仅可以了解采样前后信号时域和频域特性的变化以及信号信息不丢失的条件,而且可以加深对离散傅里叶变换、Z 变换和序列傅里叶变换之间关系式的理解。
对连续信号()a x t 以T 为采样间隔进行时域等间隔理想采样,形成采样信号: 式中()p t 为周期冲激脉冲,()a x t 为()a x t 的理想采样。
()a x t 的傅里叶变换为()a X j Ω:上式表明将连续信号()a x t 采样后其频谱将变为周期的,周期为Ωs=2π/T 。
也即采样信号的频谱()a X j Ω是原连续信号xa(t)的频谱Xa(jΩ)在频率轴上以Ωs 为周期,周期延拓而成的。
因此,若对连续信号()a x t 进行采样,要保证采样频率fs ≥2fm ,fm 为信号的最高频率,才可能由采样信号无失真地恢复出原模拟信号ˆ()()()a a xt x t p t =1()()*()21()n a a a s X j X j P j X j jn T π∞=-∞Ω=ΩΩ=Ω-Ω∑()()n P t t nT δ∞=-∞=-∑计算机实现时,利用计算机计算上式并不方便,因此我们利用采样序列的傅里叶变换来实现,即而()()j j n n X e x n e ωω∞-=-∞=∑为采样序列的傅里叶变换2. 时域中,描述系统特性的方法是差分方程和单位脉冲响应,频域中可用系统函数描述系统特性。
已知输入信号,可以由差分方程、单位脉冲响应或系统函数求出系统对于该输入信号的响应。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
Name:Section:Laboratory Exercise 2DISCRETE-TIME SYSTEMS: TIME-DOMAIN REPRESENTATION 2.1 SIMULATION OF DISCRETE-TIME SYSTEMSProject 2.1The Moving Average SystemA copy of Program P2_1 is given below:% Program P2_1% Simulation of an M-point Moving Average Filter% Generate the input signaln = 0:100;s1 = cos(2*pi*0.05*n); % A low-frequency sinusoids2 = cos(2*pi*0.47*n); % A high frequency sinusoidx = s1+s2;% Implementation of the moving average filterM = input('Desired length of the filter = ');num = ones(1,M);y = filter(num,1,x)/M;% Display the input and output signalsclf;subplot(2,2,1);plot(n, s1);axis([0, 100, -2, 2]);xlabel('Time index n'); ylabel('Amplitude');title('Signal #1');subplot(2,2,2);plot(n, s2);axis([0, 100, -2, 2]);xlabel('Time index n'); ylabel('Amplitude');title('Signal #2');subplot(2,2,3);plot(n, x);axis([0, 100, -2, 2]);xlabel('Time index n'); ylabel('Amplitude');title('Input Signal');subplot(2,2,4);plot(n, y);axis([0, 100, -2, 2]);xlabel('Time index n'); ylabel('Amplitude');title('Output Signal');axis;Answers:Q2.1 The output sequence generated by running the above program for M = 2 with x[n] = s1[n]+s2[n] as the input is shown below.The component of the input x[n] suppressed by the discrete-time system simulated bythis program is–s2Q2.2Program P2_1 is modified to simulate the LTI system y[n] = 0.5(x[n]–x[n–1]) and process the input x[n] = s1[n]+s2[n] resulting in the output sequence shown below:s3=cos(2*pi*0.05*(n-1));s4= cos(2*pi*0.47*(n-1));z=s3+s4;y = 0.5*(x-z);The effect of changing the LTI system on the input is - Project 2.2 (Optional) A Simple Nonlinear Discrete-Time SystemA copy of Program P2_2 is given below:% Program P2_2% Generate a sinusoidal input signalclf;n = 0:200;x = cos(2*pi*0.05*n);% Compute the output signalx1 = [x 0 0]; % x1[n] = x[n+1]x2 = [0 x 0]; % x2[n] = x[n]x3 = [0 0 x]; % x3[n] = x[n-1]y = x2.*x2-x1.*x3;y = y(2:202);% Plot the input and output signalssubplot(2,1,1)plot(n, x)xlabel('Time index n');ylabel('Amplitude');title('Input Signal')subplot(2,1,2)plot(n,y)xlabel('Time index n');ylabel('Amplitude');title('Output signal');Answers:Q2.5The sinusoidal signals with the following frequencies as the input signals were used to generate the output signals:The output signals generated for each of the above input signals are displayed below:The output signals depend on the frequencies of the input signal according to the following rules:This observation can be explained mathematically as follows:Project 2.3 Linear and Nonlinear SystemsA copy of Program P2_3 is given below:% Program P2_3% Generate the input sequencesclf;n = 0:40;a = 2;b = -3;x1 = cos(2*pi*0.1*n);x2 = cos(2*pi*0.4*n);x = a*x1 + b*x2;num = [2.2403 2.4908 2.2403];den = [1 -0.4 0.75];ic = [0 0]; % Set zero initial conditionsy1 = filter(num,den,x1,ic); % Compute the output y1[n]y2 = filter(num,den,x2,ic); % Compute the output y2[n]y = filter(num,den,x,ic); % Compute the output y[n]yt = a*y1 + b*y2;d = y - yt; % Compute the difference output d[n]% Plot the outputs and the difference signalsubplot(3,1,1)stem(n,y);ylabel('Amplitude');title('Output Due to Weighted Input: a \cdot x_{1}[n] + b \cdot x_{2}[n]');subplot(3,1,2)stem(n,yt);ylabel('Amplitude');title('Weighted Output: a \cdot y_{1}[n] + b \cdot y_{2}[n]');subplot(3,1,3)stem(n,d);xlabel('Time index n');ylabel('Amplitude');title('Difference Signal');Answers:Q2.7 The outputs y[n], obtained with weighted input, and yt[n], obtained by combining the two outputs y1[n] and y2[n] with the same weights, are shown below along with the difference between the two signals:The two sequences are –same ;we can regard 10(-15) as 0The system is – a liner systemQ2.9Program 2_3 was run with the following non-zero initial conditions -ic = [2 2];The plots generated are shown below -Based on these plots we can conclude that the system with nonzero initial conditions is –as same as the zero initial condition with the time goneProject 2.4 Time-invariant and Time-varying SystemsA copy of Program P2_4 is given below:% Program P2_4% Generate the input sequencesclf;n = 0:40; D = 10;a = 3.0;b = -2;x = a*cos(2*pi*0.1*n) + b*cos(2*pi*0.4*n);xd = [zeros(1,D) x];num = [2.2403 2.4908 2.2403];den = [1 -0.4 0.75];ic = [0 0]; % Set initial conditions% Compute the output y[n]y = filter(num,den,x,ic);% Compute the output yd[n]yd = filter(num,den,xd,ic);% Compute the difference output d[n]d = y - yd(1+D:41+D);% Plot the outputssubplot(3,1,1)stem(n,y);ylabel('Amplitude');title('Output y[n]'); grid;subplot(3,1,2)stem(n,yd(1:41));ylabel('Amplitude');title(['Output due to Delayed Input x[n ?, num2str(D),']']); grid;subplot(3,1,3)stem(n,d);xlabel('Time index n'); ylabel('Amplitude');title('Difference Signal'); grid;Answers:Q2.12The output sequences y[n] and yd[n-10] generated by running Program P2_4 are shown below -These two sequences are related as follows–same, the output don’t change with the timeThe system is - Time invariant systemQ2.15 The output sequences y[n] and yd[n-10] generated by running Program P2_4 for non-zero initial conditions are shown below - ic = [5 2];These two sequences are related as follows – just as the sequences aboveThe system is–not related to the initial conditions2.2 LINEAR TIME-INVARIANT DISCRETE-TIME SYSTEMSProject 2.5Computation of Impulse Responses of LTI SystemsA copy of Program P2_5 is shown below:% Program P2_5% Compute the impulse response yclf;N = 40;num = [2.2403 2.4908 2.2403];den = [1 -0.4 0.75];y = impz(num,den,N);% Plot the impulse responsestem(y);xlabel('Time index n'); ylabel('Amplitude');title('Impulse Response'); grid;Answers:Q2.19 The first 41 samples of the impulse response of the discrete-time system of Project2.3 generated by running Program P2_5 is given below:Project 2.6 Cascade of LTI SystemsA copy of Program P2_6 is given below:% Program P2_6% Cascade Realizationclf;x = [1 zeros(1,40)]; % Generate the inputn = 0:40;% Coefficients of 4th order systemden = [1 1.6 2.28 1.325 0.68];num = [0.06 -0.19 0.27 -0.26 0.12];% Compute the output of 4th order systemy = filter(num,den,x);% Coefficients of the two 2nd order systemsnum1 = [0.3 -0.2 0.4];den1 = [1 0.9 0.8];num2 = [0.2 -0.5 0.3];den2 = [1 0.7 0.85];% Output y1[n] of the first stage in the cascadey1 = filter(num1,den1,x);% Output y2[n] of the second stage in the cascadey2 = filter(num2,den2,y1);% Difference between y[n] and y2[n]d = y - y2;% Plot output and difference signalssubplot(3,1,1);stem(n,y);ylabel('Amplitude');title('Output of 4th order Realization'); grid;subplot(3,1,2);stem(n,y2)ylabel('Amplitude');title('Output of Cascade Realization'); grid;subplot(3,1,3);stem(n,d)xlabel('Time index n');ylabel('Amplitude');title('Difference Signal'); grid;Answers:Q2.23The output sequences y[n], y2[n], and the difference signal d[n] generated by running Program P2_6 are indicated below:The relation between y[n] and y2[n] is– y[n] is the Convolution of y2[n] and y1[n]The 4th order system can do the same job as the cascade systemQ2.24 The sequences generated by running Program P2_6 with the input changed to asinusoidal sequence are as follows:x = sin(2*pi*0.05*n);The relation between y[n] and y2[n] in this case is–same as the relation aboveProject 2.7 ConvolutionA copy of Program P2_7 is reproduced below:% Program P2_7clf;h = [3 2 1 -2 1 0 -4 0 3]; % impulse responsex = [1 -2 3 -4 3 2 1]; % input sequencey = conv(h,x);n = 0:14;subplot(2,1,1);stem(n,y);xlabel('Time index n'); ylabel('Amplitude');title('Output Obtained by Convolution'); grid;x1 = [x zeros(1,8)];y1 = filter(h,1,x1);subplot(2,1,2);stem(n,y1);xlabel('Time index n'); ylabel('Amplitude');title('Output Generated by Filtering'); grid;Answers:Q2.28 The sequences y[n] and y1[n] generated by running Program P2_7 are shown below:The difference between y[n] and y1[n] is - sameThe reason for using x1[n]as the input, obtained by zero-padding x[n], for generating y1[n] is–the length of x is 7,but the length of the Convolution is 14,and n=14,we need the length of filter to be 14Project 2.8 Stability of LTI SystemsA copy of Program P2_8 is given below:% Program P2_8% Stability test based on the sum of the absolute% values of the impulse response samplesclf;num = [1 -0.8]; den = [1 1.5 0.9];N = 200;h = impz(num,den,N+1);parsum = 0;for k = 1:N+1;parsum = parsum + abs(h(k));if abs(h(k)) < 10^(-6), break, endend% Plot the impulse responsen = 0:N;stem(n,h)xlabel('Time index n'); ylabel('Amplitude');% Print the value of abs(h(k))disp('Value =');disp(abs(h(k)));Answers:Q2.32The discrete-time system of Program P2_8 is -[h,t] = impz(hd) computes the instantaneous impulse response of the discrete-time filter hd choosing the number of samples for you, and returns theresponse in column vector h and a vector of times or sample intervalsin t where (t = [0 1 2...]'). impz returns a matrix h if hd is avector. Each column of the matrix corresponds to one filter in thevector. When hd is a vector of discrete-time filters, impz returns thematrix h. Each column of h corresponds to one filter in the vector hd. impz(hd) uses FVTool to plot the impulse response of the discrete-time filter hd. If hd is a vector of filters, impz plots the response and for eachfilter in the vector.The impulse response generated by running Program P2_8 is shown below:The value of |h(K)| here is - 1.6761e-005From this value and the shape of the impulse response we can conclude that the system is - ?By running Program P2_8 with a larger value of N the new value of |h(K)| is -9.1752e-007N = 400;From this value we can conclude that the system is - ? Project 2.9 Illustration of the Filtering ConceptA copy of Program P2_9 is given below:% Program P2_9% Generate the input sequenceclf;n = 0:299;x1 = cos(2*pi*10*n/256);x2 = cos(2*pi*100*n/256);x = x1+x2;% Compute the output sequencesnum1 = [0.5 0.27 0.77];y1 = filter(num1,1,x); % Output of System #1den2 = [1 -0.53 0.46];num2 = [0.45 0.5 0.45];y2 = filter(num2,den2,x); % Output of System #2% Plot the output sequencessubplot(2,1,1);plot(n,y1);axis([0 300 -2 2]);ylabel('Amplitude');title('Output of System #1'); grid;subplot(2,1,2);plot(n,y2);axis([0 300 -2 2]);xlabel('Time index n'); ylabel('Amplitude');title('Output of System #2'); grid;Answers:Q2.34The output sequences generated by this program are shown below:The filter with better characteristics for the suppression of the high frequency component of the input signal x[n] is–system#2Date: Signature:。