数字信号处理实验报告2
实验报告本
课程名称数字信号与处理实验
实验学期2013年至2014第一学期
学生所在学院光电工程学院
年级11专业班级测控技术与仪器
学生姓名学号
指导教师签名
实验最终成绩
重庆大学光电工程学院教学实验中心制
实验题目
用FFT进行谱分析
实验时间
2013年11月24日
实验地点
主教1108
三、使用仪器、器材
计算机、matlab软件
四、实验步骤
1、复习DFT的定义、性质和用DFT做谱分析的有关内容。
2,复习FFT算法原理与编程思想,并对照DITFFT运算流图和程序框图,读懂本实验提供的FFT子程序。
3、编制信号产生子程序,产生实验所要求的典型信号供谱分析用。
4/按实验内容要求,上上机实验,并写出实验报告。
2
3ห้องสมุดไป่ตู้
4
5
六、实验结果分析
思考题:
1、说明FFT长度N改变对频谱的影响
答:FFT随长度N增加,主瓣宽度减小,分辨率提高,主峰位置也较准确。
2、在N=8时,x2(n)和x3(n)的幅频特性会相同吗?为什么?N=16呢?
答:不相同。当N=8时,序列x1(n)和x2(n)中相同的元素值对应的n值是不同的,所乘的旋转因子的值也不同,因而得到的最终结果也是不同的。同理,N=16时,所得的幅频特性也是不同的。
3、FFT在什么条件下也可以用来分析周期信号序列的频谱?如果正弦信号系统sin(2πf0k),f0=0.1Hz,用16点FFT来做DFT运算,得到的频谱是信号本身的真实谱吗?为什么?
答:由于FFT算法对序列长度的要求是N=2^M,M为正整数。所以,当周期信号序列一个周期的长度满足N=2^M(M为正整数)的条件时,FFT可以用来分析周期信号的频谱。不是真实的频谱。因为序列的周期N=10不是2的整数次幂,所以不是真实的。
(3)学习用FFT对连续信号和时域离散信号进行谱分析的方法,了解可能出现的分析误差及其原因,以便在实际中正确应有FFT。
二、实验原理
在各种信号序列中,有限长序列信号处理占有很重要地位,对有限长序列,我们可以使用离散傅里叶变换(DFT)。这一变换不但可以很好的反映序列的频谱特性,而且易于用快速算法在计算机上实现,有限长序列的DFT是其Z变换在单位圆上的等距采样,或者说是序列Fourier变换的等距采样,因此可以用于序列的谱分析。
FFT并不是与DFT不同的另一种变换,而是为了减少DFT运算次数的一种快速算法。它是对变换式进行一次次分解,使其成为若干小点数的组合,从而减少运算量。常用的FFT是以2为基数的,其长度。它的效率高,程序简单,使用非常方便,当要变换的序列长度不等于2的整数次方时,为了使用以2为基数的FFT,可以用末位补零的方法,使其长度延长至2的整数次方。一个序列x(n)的离散时间傅里叶变换就是它的频谱函数。
实验成绩
实验性质
□验证性□设计性□综合性
教师评语:
□出勤率好□原理正确□方案合理
□实验结果正确□回答问题正确□报告规范
一、实验目的
(1)进一步加深DFT算法原理和基本性质的理解(因为FFT只是DFT的一种快速算法,所以FFT的运算结果必然满足DFT的基本性质)。熟悉FFT程序结构及编程方法。
(2)熟悉应用FFT对确定信号进行谱分析方法,熟悉FFT算法原理和FFT子程序的应用。
数字信号处理实验报告2
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 by thisprogram 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 \cdotx_{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.15The 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 Project 2.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] andy1[n]The 4th order system can do the same job as the cascade systemQ2.24The sequences generated by running Program P2_6 with the input changed to a sinusoidal 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 generatingy1[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 the response in column vector h and a vector of times or sample intervals in t where (t = [0 1 2...]'). impz returns a matrix h if hd is a vector. Each column of the matrix corresponds to one filter in the vector. When hd is a vector of discrete-time filters, impz returns the matrix 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 each filter 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:。
数字信号处理实验报告 (2)
实验一信号、系统及系统响应一、实验目的1、熟悉连续信号经理想采样前后的频谱变化关系,加深对时域采样定的理解。
2、熟悉时域离散系统的时域特性。
3、利用卷积方法观察分析系统的时域特性。
4、掌握序列傅里叶变换的计算机实现方法,利用序列的傅里叶变换对连续信号、离散信号及系统响应进行频域分析。
二、实验原理采样的的过程既是连续信号离散化的过程。
采用单位冲击串进行采样,为使采样信号能不失真的还原为采样前的信号,根据奈奎斯特采样率,采样频率应该大于信号最高频率的2倍。
因为时域的采样既是对时域的离散化处理,时域离散频域会进行周期延拓,为了防止频域频谱混叠,必须满足奈奎斯特采样定律。
线性卷积的过程为:反褶,移位,相乘,相加。
设一个N1点的序列与一个N2的序列进行卷积则得到N1+N2-1点的序列。
时域卷积,对应频域的相乘。
序列的傅里叶变换即DTFT 。
具有的性质有: 线性,移位性,对偶性,等等。
三、实验内容及步骤1)分析采样序列的特性。
产生采样序列()a x n ,A 444.128=,a =,0Ω=。
a 、 取采样频率s f 1kHz =,即T 1ms =。
观察所采样()a x n 的幅频特性()j X e ω和)(t x a 的幅频特性()X j Ω在折叠频率处有无明显差别。
应当注意,实验中所得频谱是用序列的傅立叶变换公式求得的,所以在频率量度上存在关系:T ω=Ω。
b 、改变采样频率,s f 300Hz =,观察()j X eω的变化并做记录。
c 、 进一步降低采样频率,s f 200Hz =,观察频谱混叠是否明显存在,说明原因,并记录()j X e ω的幅频曲线。
上图是采用不同采样频率时所得到的序列及其对应的傅里叶变换,从图中可以看到,当采样频率比较低时,频谱会发生混叠,且频率越低,混叠现象越明显。
增大采样频率可以有效地防止混叠。
2) 离散信号、系统和系统响应分析。
a 、观察信号()b x n 和系统h ()b n 的时域和频域持性;利用线形卷积求信号()b x n 通过系统h ()b n 的响应y(n),比较所求响应y(n)和h ()b n 的时域及频域特性,注意它们之间有无差异,绘图说明,并用所学结论解释所得结果。
数字信号处理实验报告(二)
数字信号处理第二次实验报告学院:信息工程学院班级:2012级电子信息工程*班姓名:学号:20125507**指导老师:实验四:IIR数字滤波器设计及软件实现一、实验目的1、熟悉双线性变换设计IIR滤波器的原理与方法2、掌握IIR滤波器的MATLAB实现方法二、实验原理简述IIR数字滤波器间接法基本设计过程:1、将给定的数字滤波器的指标转换成过渡模拟滤波器的指标;2、设计过渡模拟滤波器;3、将过渡模拟滤波器系统函数转换成数字滤波器的系统函数三、程序与图形1、%-----------------信号产生函数mstg---------------function st=mstg %功能函数的写法%产生信号序列向量st,并显示st的时域波形和频谱%st=mstg 返回三路调幅信号相加形成的混合信号,长度N=1600N=1600 %N为信号st的长度。
Fs=10000;T=1/Fs;Tp=N*T; %采样频率Fs=10kHz,Tp为采样时间t=0:T:(N-1)*T;k=0:N-1;f=k/Tp;fc1=Fs/10; %第1路调幅信号的载波频率fc1=1000Hz,fm1=fc1/10; %第1路调幅信号的调制信号频率fm1=100Hzfc2=Fs/20; %第2路调幅信号的载波频率fc2=500Hzfm2=fc2/10; %第2路调幅信号的调制信号频率fm2=50Hzfc3=Fs/40; %第3路调幅信号的载波频率fc3=250Hz,fm3=fc3/10; %第3路调幅信号的调制信号频率fm3=25Hzxt1=cos(2*pi*fm1*t).*cos(2*pi*fc1*t); %产生第1路调幅信号xt2=cos(2*pi*fm2*t).*cos(2*pi*fc2*t); %产生第2路调幅信号xt3=cos(2*pi*fm3*t).*cos(2*pi*fc3*t); %产生第3路调幅信号st=xt1+xt2+xt3; %三路调幅信号相加fxt=fft(st,N); %计算信号st的频谱%-------绘制st的时域波形和幅频特性曲线-----subplot(2,1,1)plot(t,st);grid;xlabel('t/s');ylabel('s(t)');axis([0,Tp/8,min(st),max(st)]);title('(a) s(t)的波形')subplot(2,1,2)stem(f,abs(fxt)/max(abs(fxt)),'.');grid;title('(b) s(t)的频谱') axis([0,Fs/5,0,1.2]);xlabel('f/Hz');ylabel('幅度')-10123t/ss (t )(b) s(t)的频谱f/Hz幅度2、%-------实验4-2--------- clear all;close allFs=10000;T=1/Fs; %采样频率%调用信号产生函数mstg 产生由三路抑制载波调幅信号相加构成的复合信号st st=mstg;fp=280;fs=450; %下面wp,ws,为fp,fs 的归一化值范围为0-1wp=2*fp/Fs;ws=2*fs/Fs;rp=0.1;rs=60; %DF 指标(低通滤波器的通、阻带边界频)[N,wp]=ellipord(wp,ws,rp,rs); %调用ellipord 计算椭圆DF 阶数N 和通带截止频率wp[B,A]=ellip(N,rp,rs,wp); %调用ellip 计算椭圆带通DF 系统函数系数向量B 和A[h,w]= freqz(B,A);y1t=filter(B,A,st); %滤波器软件实现 figure(2);subplot(2,1,1); plot(w,20*log10(abs(h))); axis([0,1,-80,0]) subplot(2,1,2);t=0:T:(length(y1t)-1)*T; plot(t,y1t);%axis([0,1,-80,0])-10123t/ss (t )(b) s(t)的频谱f/Hz幅度-80-60-40-20000.020.040.060.080.10.120.140.16-1-0.500.511.53、%-------实验4-3---------fpl=440;fpu=560;fsl=275;fsu=900;wp=[2*fpl/Fs,2*fpu/Fs];ws=[2*fsl/Fs,2*fsu/Fs];rp=0.1;rs=60;[N,wp]=ellipord(wp,ws,rp,rs); %调用ellipord 计算椭圆DF 阶数N 和通带截止频率wp[B,A]=ellip(N,rp,rs,wp); %调用ellip 计算椭圆带通DF 系统函数系数向量B 和A[h,w]= freqz(B,A); y2t=filter(B,A,st);figure(3);subplot(2,1,1);plot(w,20*log10(abs(h))); axis([0,1,-80,0]) subplot(2,1,2);t=0:T:(length(y2t)-1)*T; plot(t,y2t);00.20.40.60.81-80-60-40-20000.020.040.060.080.10.120.140.16-2-10124、%-------实验4-4--------- fp=900;fs=550;wp=2*fp/Fs;ws=2*fs/Fs;rp=0.1;rs=60; %DF 指标(低通滤波器的通、阻带边界频)[N,wp]=ellipord(wp,ws,rp,rs);%调用ellipord 算椭圆DF 阶数N 通带截止频率 [B,A]=ellip(N,rp,rs,wp,'high'); %调用ellip 计算椭圆带通DF 系统函数系数向量B 和A[h,w]= freqz(B,A); y3t=filter(B,A,st);figure(4);subplot(2,1,1); plot(w,20*log10(abs(h))); axis([0,1,-80,0]) subplot(2,1,2);t=0:T:(length(y3t)-1)*T; plot(t,y3t);-80-60-40-20000.020.040.060.080.10.120.140.16-2-1012四、实验结果分析由图可见,三个分离滤波器指标参数选取正确,损耗函数曲线达到所给指标。
数字信号处理实验报告
数字信号处理报告IIR数字滤波器上海理工大学教师:苏湛组员:王世豪徐骞刘新2016.1.4一、实验简介Butterworth 和Chebyshev 低通滤波器方法:1) 根据性能参数,先设计一个模拟滤波器,按照一定的算法转换为满足预定指标的数字滤波器。
利用模拟原型滤波器的逼近算法和特性。
2)计算机辅助设计,从统计概念出发,对所要提取的有用信号从时域进行估计,在统计指标最优的意义下,使得估计值最优逼近有用信号,减弱或消除噪声。
1)Butterworth 低通滤波器 1 幅频特性:21|()|1()a NcH j Ω=Ω+Ω,其中N 为滤波器的阶数,c Ω为通带截止频率。
在Ω=0处,有最大值|(0)|1a H =;2)在通带截止频率c Ω=Ω处,不同阶次的幅频量值都相同,即为|()|0.707|(0)|a a H j H Ω=;3)阶数N 增加时,通带幅频特性变平,阻带衰减更快,逐渐趋近于理想滤波器的幅频特性。
幅频特性通常用衰减函数1020log |()/(0)|a a H j H α=-Ω描述。
分贝(dB ) 2 极点一共有2N 个,并且以圆点为对称中心成对的出现。
21()22k j N k c s eππ-+=Ω k=1,2,…,N系统函数:122()()()()N a c N KH s K s s s s s s ==Ω--- …3 通带衰减函数p α、阻带衰减函数s α 和系统幅频特性20log |()|a H j -Ω的关系:10p 20log |()|a p H j α-Ω≤Ω≤Ω p Ω为通带截止频率 10s 20log |()|a s H j α-Ω≥Ω≥Ω s Ω为阻带截止频率4 阶数N 0.10.11010log [(101)/(101)]2log (/)p s p s N αα----≥ΩΩ5 通带截止频率c Ω 0.10.11/21/2(101)(101)ps psc NNαα--ΩΩΩ==--确定了滤波器的阶数N 和通带截止频率c Ω,就可以求出系统的极点,从而求出系统函数()a H s ,这样就完成了Butterworth 低通滤波器的设计。
“数字信号处理”实验报告二
实验报告课程名称:数字信号处理实验任课教师:杨鉴实验名称:离散时间系统的时域分析年级、专业:2015级通信工程学号:**********姓名:***日期:2017 年10 月9 日云南大学信息学院一、实验1.通过MATLAB仿真一些简单的离散时间系统,并研究他们的时域特性。
2.掌握卷积在MATLAB的算法并理解滤波的概念。
二、实验内容1. 假定另一个系统为y[n]=x[n]x[n-1],修改程序P2.3,计算这个系统的输出序列y1[n],y2[n]和y[n]。
比较y[n]和yt[n]。
这两个序列是否相等?该系统是线性系统吗?2. 考虑另一个系统:y[n]=nx[n]+x[n-1],修改程序P2.4,以仿真上面的系统并确定该系统是否为时不变系统。
3.修改程序P2.7,计算长度为15的序列h[n]和长度为10的序列x[n]的卷积,重做问题Q2.28。
h[n]和x[n]的样本值你自己给定。
4.修改程序P2.9,将输入序列改变成扫频正弦序列(长度为301、最低频率为0、最高频率为0.5)。
那个滤波器能更好的抑制输入信号x[n]的高频分量?三、主要算法与程序Q2.11:clf;n = 0:40;a = 2;b = -3;f1=0.1;f2=0.4;x11=[0 cos(2*pi*f1*n) 0];x12=[0 0 cos(2*pi*f1*n)];x21=[0 cos(2*pi*f2*n) 0];x22=[0 0 cos(2*pi*f2*n)];x = a*x11 + b*x21;y1 = x11.*x12;y2 = x21.*x22;xd = a*x12+b*x22;y = x.*xd;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([0 n 0],y);ylabel('Amplitude');title('Output Due to Weighted Input: a \cdot x_{1}[n] + b \cdot x_{2}[n]');subplot(3,1,2)stem([0 n 0],yt);ylabel('Amplitude');title('Weighted Output: a \cdot y_{1}[n] + b \cdot y_{2}[n]'); subplot(3,1,3)stem([0 n 0],d);xlabel('Time index n');ylabel('Amplitude');title('Difference Signal');Q2.17:clf;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];nd=0:length(xd)-1;y=(n.*x)+[0 x(1:40)];yd=(nd.*xd)+[0 xd(1:length(xd)-1)];d = y - yd(1+D:41+D);subplot(3,1,1)stem(n,y);ylabel('振幅');title('输出 y[n]'); grid;subplot(3,1,2)stem(n,yd(1:41));ylabel('振幅');title('由于延时输入 x[n-10]的输出'); grid;subplot(3,1,3)stem(n,d);xlabel('时间序号 n'); ylabel('振幅');title('差值信号');grid;Q2.29:clf;h = [3 2 1 -2 1 0 -4 0 3 1 5 4 0 3 5]; % impulse responsex = [1 -2 3 -4 3 2 1 5 6 1]; % input sequencey = conv(h,x);n = 0:23;subplot(2,1,1);stem(n,y);xlabel('时间序号n');ylabel('振幅');title('用卷积得到的输出'); grid;x1 = [x zeros(1,14)];y1 = filter(h,1,x1);subplot(2,1,2);stem(n,y1);xlabel('时间序号 n'); ylabel('振幅');title('由滤波生成的输出'); grid;Q2.35:f=w/2pi=(2a*n+b)/2pi=[0,0.5],所以b=0,a*n<=0.5*pi,当n=300时,a取pi/600。
数字信号处理实验报告一二
数字信号处理课程实验报告实验一 离散时间信号和系统响应一. 实验目的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. 时域中,描述系统特性的方法是差分方程和单位脉冲响应,频域中可用系统函数描述系统特性。
已知输入信号,可以由差分方程、单位脉冲响应或系统函数求出系统对于该输入信号的响应。
数字信号处理实验报告二与三
实验二 用FFT 进行谱分析一.实验目的:1 进一步加深DFT 算法原理和基本性质的理解(因为FFT 只是DFT 的一种快速算法,所以FFT 的运算结果必然满足DFT 的基本性质)。
熟悉FFT 程序结构及编程方法。
2 熟悉应用FFT 对确定信号进行谱分析方法,熟悉FFT 算法原理和FFT 子程序的应用。
3 学习用FFT 对连续信号和时域离散信号进行谱分析的方法,了解可能出现的分析误差及其原因,以便在实际中正确应有FFT 。
二.实验内容:(1)用matlab 编程产生并画出信号x1(n)、x2(n)、x3(n)、x4(n)、x5(n)。
(2)用matlab 编制FFT 函数对上述信号进行频谱分析,并画出上述信号谱图。
三.实验结果(1)1.%This programm is to generate signal x1(n)=R4(n).k=-6:6;x=[zeros(1,6),ones(1,4),zeros(1,3)];stem(k,x); (信号图如图1) title('图1');2.n=-5:1:10;x=(n+1).*(n>=0 & n<=3)+(8-n).*(n>=4 & n<=7)+0; stem(n,x); title('图2');3.n=-5:10;x=(4-n).*(n>=0 & n<=3)+(n-3).*(n>=4 & n<=7); stem(n,x); title('图3');-6-4-2024600.10.20.30.40.50.60.70.80.91⎪⎩⎪⎨⎧≤≤-≤≤+==n n n n n n x n R n x 其它,074,830,1)()()(241⎪⎩⎪⎨⎧≤≤-≤≤-=n n n n n n x 其它,074,330,4)(3n n x 4cos )(4π=n n x 8sin )(5π=图1-5051000.511.522.533.54-5051000.511.522.533.54图34.n=-10:10; x=cos(pi/4*n); stem(n,x); title('图4');5.n=-10:10;x=sin(pi/8*n); stem(n,x); title('图5');实验结果(2): FFT 算法function y=myditfft(x) % y=myditfft(x)% 本程序对输入序列 x 实现DIT-FFT 基2算法,点数取大于等于x 长度的2的幂次 % x 为给定时间序列% y 为x 的离散傅立叶变换m=nextpow2(x);N=2^m; % 求x 的长度对应的2的最低幂次m if length(x)<N;% 若x 的长度不是2的幂,补零到2的整数幂 x=[x,zeros(1,N-length(x))]; endnxd=bin2dec(fliplr(dec2bin([1:N]-1,m)))+1; % 求1:2^m 数列的倒序 y=x(nxd); % 将x 倒序排列作为y 的初始值 for mm=1:m; % 将DFT 作m 次基2分解,从左到右,对每次分解作DFT 运算 Nmr=2^mm;u=1; % 旋转因子u 初始化为WN^0=1WN=exp(-i*2*pi/Nmr); % 本次分解的基本DFT 因子WN=exp(-i*2*pi/Nmr) for j=1:Nmr/2; % 本次跨越间隔内的各次蝶形运算for k=j:Nmr:N; % 本次蝶形运算的跨越间隔为Nmr=2^mm kp=k+Nmr/2; % 确定蝶形运算的对应单元下标 t=y(kp)*u; % 蝶形运算的乘积项 y(kp)=y(k)-t; % 蝶形运算 y(k)=y(k)+t; % 蝶形运算 endu=u*WN; % 修改旋转因子,多乘一个基本DFT 因子WN end-10-8-6-4-2246810-1-0.8-0.6-0.4-0.200.20.40.60.81图4-10-8-6-4-2246810-1-0.8-0.6-0.4-0.200.20.40.60.81图5end 1.k=-6:6;x=[zeros(1,6),ones(1,4),zeros(1,3)]; y=myditfft(x); k=-6:9; stem(k,y); xlabel('m'); ylabel('X[M]');title('FFT 图');2.n=-5:1:10;x=(n+1).*(n>=0 & n<=3)+(8-n).*(n>=4 & n<=7)+0;y=myditfft(x); stem(n,y); xlabel('n'); ylabel('X[M]'); title('FFT 图'); 3.n=-5:10;x=(4-n).*(n>=0 & n<=3)+(n-3).*(n>=4 & n<=7); y=myditfft(x); stem(n,y); xlabel('n'); ylabel('X[M]'); title('FFT3'); 4.n=-10:10;x=cos(pi/4*n); y=myditfft(x); n=-10:21; stem(n,y); xlabel('n'); ylabel('X[M]'); title('FFT4'); 5.n=-10:10;x=sin(pi/8*n); y=myditfft(x); n=-10:21; stem(n,y); xlabel('n'); ylabel('X[M]'); title('FFT5');-6-4-20246810-4-3-2-101234m X [M ]FFT 图-5510-20-15-10-505101520nX [M ]FFT 图-5510-10-55101520nX M FFT3-10-50510152025-4-3-2-1012345n X [M ]FFT4-10-50510152025-6-4-22468nX [M ]FFT5四.简要回答以下问题:①在N=8时,x2(n)和x3(n)的幅频特性会相同吗?为什么?N=16呢?答:不相同。
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('时域恢复');。
数字信号处理实验报告完整版[5篇模版]
数字信号处理实验报告完整版[5篇模版]第一篇:数字信号处理实验报告完整版实验 1利用 T DFT 分析信号频谱一、实验目的1.加深对 DFT 原理的理解。
2.应用 DFT 分析信号的频谱。
3.深刻理解利用DFT 分析信号频谱的原理,分析实现过程中出现的现象及解决方法。
二、实验设备与环境计算机、MATLAB 软件环境三、实验基础理论T 1.DFT 与与 T DTFT 的关系有限长序列的离散时间傅里叶变换在频率区间的N 个等间隔分布的点上的 N 个取样值可以由下式表示:212 /0()|()()0 1Nj knjNk NkX e x n e X k k Nπωωπ--====≤≤-∑由上式可知,序列的 N 点 DFT ,实际上就是序列的 DTFT 在 N 个等间隔频率点上样本。
2.利用 T DFT 求求 DTFT方法 1 1:由恢复出的方法如下:由图 2.1 所示流程可知:101()()()Nj j n kn j nNn n kX e x n e X k W eNωωω∞∞----=-∞=-∞=⎡⎤==⎢⎥⎣⎦∑∑∑由上式可以得到:IDFT DTFT第二篇:数字信号处理实验报告JIANGSUUNIVERSITY OF TECHNOLOGY数字信号处理实验报告学院名称:电气信息工程学院专业:班级:姓名:学号:指导老师:张维玺(教授)2013年12月20日实验一离散时间信号的产生一、实验目的数字信号处理系统中的信号都是以离散时间形态存在的,所以对离散时间信号的研究是数字信号的基本所在。
而要研究离散时间信号,首先需要产生出各种离散时间信号。
使用MATLAB软件可以很方便地产生各种常见的离散时间信号,而且它还具有强大绘图功能,便于用户直观地处理输出结果。
通过本实验,学生将学习如何用MATLAB产生一些常见的离散时间信号,实现信号的卷积运算,并通过MATLAB中的绘图工具对产生的信号进行观察,加深对常用离散信号和信号卷积和运算的理解。
数字信号处理实验报告
数字信号处理实验报告实验一:混叠现象的时域与频域表现实验原理:当采样频率Fs不满足采样定理,会在0.5Fs附近引起频谱混叠,造成频谱分析误差。
实验过程:考虑频率分别为3Hz,7Hz,13Hz 的三个余弦信号,即:g1(t)=cos(6πt), g2(t)=cos(14πt), g3(t)=cos(26πt),当采样频率为10Hz 时,即采样间隔为0.1秒,则产生的序列分别为:g1[n]=cos(0.6πn), g2[n]=cos(1.4πn), g3[n]=cos(2.6πn)对g2[n],g3[n] 稍加变换可得:g2[n]=cos(1.4πn)=cos((2π-0.6π)n)= cos(0.6πn)g3[n]=cos(2.6πn)= cos((2π+0.6π)n)=cos(0.6πn)利用Matlab进行编程:n=1:300;t=(n-1)*1/300;g1=cos(6*pi*t);g2=cos(14*pi*t);g3=cos(26*pi*t);plot(t,g1,t,g2,t,g3);k=1:100;s=k*0.1;q1=cos(6*pi*s);q2=cos(14*pi*s);q3=cos(26*pi*s);hold on; plot(s(1:10),q1(1:10),'bd');figuresubplot(2,2,1);plot(k/10,abs(fft(q1)))subplot(2,2,2);plot(k/10,abs(fft(q2)))subplot(2,2,3);plot(k/10,abs(fft(q3)))通过Matlab软件的图像如图所示:如果将采样频率改为30Hz,则三信号采样后不会发生频率混叠,可运行以下的程序,观察序列的频谱。
程序编程改动如下:k=1:300;q=cos(6*pi*k/30);q1=cos(14*pi*k/30);q2=cos(26*pi*k/30);subplot(2,2,1);plot(k/10,abs(fft(q)))subplot(2,2,2);plot(k/10,abs(fft(q1)))subplot(2,2,3);plot(k/10,abs(fft(q2)))得图像:问题讨论:保证采样后的信号不发生混叠的条件是什么?若信号的最高频率为17Hz,采样频率为30Hz,问是否会发生频率混叠?混叠成频率为多少Hz的信号?编程验证你的想法。
