哈工大数字信号处理实验报告(共21页)_第1页
哈工大数字信号处理实验报告(共21页)_第2页
哈工大数字信号处理实验报告(共21页)_第3页
哈工大数字信号处理实验报告(共21页)_第4页
哈工大数字信号处理实验报告(共21页)_第5页
已阅读5页,还剩17页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、 Harbin Institute of Technology数字(shz)信号处理(xn ho ch l)实验报告学生姓名: 江世凯学号: 1122110307班级: 1221103专业: 电子科学与技术任课教师: 李杨所 在 单 位: 电子工程系2014年11月 实验(shyn)一、用FFT作谱分析一、实验(shyn)目的(1) 进一步加深(jishn)DFT算法原理和基本性质的理解(因为FFT只是DFT的一种快速算法, 所以FFT的运算结果必然满足DFT的基本性质)。(2) 熟悉FFT算法原理和FFT子程序的应用。(3) 学习用FFT对连续信号和时域离散信号进行谱分析的方法,了解可能出现

2、的分析误差及其原因,以便在实际中正确应用FFT。二、实验内容(1) 编制信号产生子程序, 产生以下典型信号供谱分析用: (2) 画出1 中所给出的信号,并逐个进行谱分析。 下面给出针对各信号的FFT变换区间N以及对连续信号x6(t)的采样频率fs, 供实验时参考。 x1(n), x2(n), x3(n), x4(n), x5(n): N=8, 16 x6(t): fs=64(Hz), N=16, 32, 64(n=0:1:69)(3) 令x(n)=x4(n)+x5(n), 用FFT计算 8 点和 16 点离散傅里叶变换, X(k)=DFTx(n)(4) 令x(n)=x4(n)+jx5(n),

3、重复(2)。三、程序框图图1.实验(shyn)程序框图四、实验(shyn)过程(1) 复习(fx)DFT的定义、 性质和用DFT作谱分析的有关内容。(2) 复习FFT算法原理与编程思想, 并对照DIT-FFT运算流图和程序框图, 读懂本实验提供的FFT子程序。(3) 编制信号产生子程序, 产生以下典型信号供谱分析用: (4) 编写(binxi)主程序。(5) 按实验(shyn)内容要求, 上机实验, 并写出实验报告。五、实验结果(ji gu)及分析1.实验结果(1)对x1(n)进行FFT变换(N=8和N=16) 图2 x1(n)进行FFT变换结果(2)对x2(n)进行FFT变换(N=8和N=1

4、6) 图3 x2(n)FFT变换(binhun)结果(3)对x3(n)进行(jnxng)FFT变换(N=8和N=16) 图4 x3(n) FFT变换(binhun)结果(4)对x4(n)进行(jnxng)FFT变换(N=8和N=16) 图5 x4(n) FFT变换(binhun)结果(5)对x5(n)进行(jnxng)FFT变换(N=8和N=16) 图6 x5(n) FFT变换结果(6)对x6(n)进行(jnxng)FFT变换(N=16、N=32和N=64) 图7 x6(n) FFT变换(binhun)结果(7)对x(n)=x4(n)+x5(n)进行(jnxng)FFT变换(N=8和N=16)

5、 图8 x4(n)+x5(n) FFT变换(binhun)结果(8)对x(n)=x4(n)+jx5(n)进行(jnxng)FFT变换(N=8和N=16) 图9 x4(n)+jx5(n)FFT变换(binhun)结果(9)GUI设计结果2.分析(fnx):(1) 在N=8时,x2(n)和x3(n)的幅频特性会相同(xin tn)吗? 为什么? N=16呢?答:在N=8的时候,x3(n)只是(zhsh)x2(n)以它的长度8为周期,将其延拓成周期序列然后加以移位,最后截取主值区间(n=0到8)的序列值,因此x3(n)是x2(n)进行循环位移后的结果。由于序列的循环位移性质,因此,循环位移只影响到D

6、FT后的相频特性,而不影响幅频特性,因此x2(n)和x3(n)的幅频特性会相同。若N=16,此时,x2(n)和x3(n)做DFT即为它们分别进行末尾补零后再进行的DFT,则此时两个经过补零以后的序列就不满足循环位移的性质,因此x2(n)和x3(n)的幅频特性就会发生变化。(2) 如果周期信号的周期预先不知道, 如何用FFT进行谱分析答:在用FFT对信号进行频谱分析时,首先要对信号进行采样,使之变成离散信号,然后就可按照前面的方法用FFT对离散信号进行频谱分析。按照采样定理,采样频率fs应当大于信号最高频率的2倍。若预先不知道周期信号的周期,应先适当截取M点进行FFT,再将截取的长度扩大1倍重新

7、截取,比较二者结果,若二者的差别满足分析误差的要求,就可以近似得到该信号的频谱,假若不满足误差要求则继续加倍截取的长度进行FFT,直到结果满足误差要求为止。(3) 结合实验中所得给定典型序列幅频特性曲线,与理论结果比较, 并分析说明误差产生的原因以及用FFT作谱分析时有关参数的选择方法。答:1. 误差(wch)分析:1)对于(duy)x1(n)理论FFT频谱为一个抽样信号,由图2可以看出,随着采样率的提高,得到的FFT频谱分辨率就越高,当N趋于无限时频谱包络接近(jijn)理论的抽样函数。 2)序列x2(n)理论FFT频谱为一个抽样函数平方的信号,由图3看出,随着采样率的提高,得到的FFT频谱

8、分辨率就越高,当N趋于无限时频谱包络接近理论的抽样函数。 3)对于x3(n),由图4看出,随着采样率的提高,得到的FFT频谱分辨率就越高,但对于这个函数来说,N仍然过小,因此幅频特性曲线与理论结果有较大差距。 4)序列x4(n)的理论FFT抽样频谱为单位冲激函数,因此只要满足抽样定理,FFT都可以与理论图形一样的曲线。由图5可以看出,当N=8,16时,满足抽样定理,能够得到与理论一致的曲线。 5)序列x5(n)的理论FFT抽样频谱为单位冲激函数,因此只要满足抽样定理,FFT都可以与理论图形一样的曲线。由图6可知,当N=8时,不满足抽样定理,因此产生了混叠失真,当N=8时,满足抽样定理,因此可得

9、到与理论曲线一致的图形。 6)序列x6(n)的理论FFT抽样频谱为有三个不同频率分量的单位冲激函数,因此只要满足抽样定理,FFT都可以与理论图形一样的曲线。当N=16时,不满足抽样定理,因此产生了混叠失真,当N=32,64时,满足抽样定理,因此可得到与理论曲线一致的图形,如图7所示。 7)函数x4(n)+x5(n) 理论FFT抽样频谱为有两个不同频率分量的单位冲激函数,因此只要满足抽样定理,FFT都可以与理论图形一样的曲线。当N=8时,不满足抽样定理,因此产生了混叠失真,当N=16时,满足抽样定理,因此可得到与理论曲线一致的图形,如图8所示。 8)序列x4(n)+jx5(n) 理论FFT抽样频

10、谱为有两个不同频率分量的单位冲激函数,因此只要满足抽样定理,FFT都可以与理论图形一样的曲线。如图9所示,当N=8时,不满足抽样定理,因此产生了混叠失真,当N=16时,满足抽样定理,因此可得到与理论曲线一致的图形。2. 参数选择;对时间序列做FFT变换时,抽样频率要要一些,从而提高分辨率减小误差,同时抽样频率的选取必须满足抽样定理才能得到与理论相符的曲线。 六、实验源程序对x1(n)进行(jnxng)FFT变换(N=8和N=16)function output_args = Untitled1( input_args )%UNTITLED1 Summary of this function g

11、oes here% Detailed explanation goes hereclear all;N=4;x=1,1,1,1;n=0:N-1;subplot(3,1,1);stem(n,abs(x),g,LineWidth,1.3);title(x1(n)时间(shjin)序列);N=8;y1=fft(x,N);n=0:N-1;subplot(3,1,2);stem(n,fftshift(abs(y1),r,LineWidth,1.3);hold on;plot(n,fftshift(abs(y1),c,LineWidth,1.3);title(FFTx1(n) : N=8);N=16;y2

12、=fft(x,N);n=0:N-1;subplot(3,1,3);stem(n,fftshift(abs(y2),m,LineWidth,1.3);hold on;plot(n,fftshift(abs(y2),y,LineWidth,1.3);title(FFTx1(n) : N=16); 对x2(n)进行(jnxng)FFT变换(N=8和N=16)function output_args = Untitled2( input_args )%UNTITLED2 Summary of this function goes here% Detailed explanation goes here

13、clear all;x=1,2,3,4,4,3,2,1;N=8;n=0:N-1;subplot(3,1,1);stem(n,abs(x),k,LineWidth,1.3);title(x2(n) 时间序列);N=8;y1=fft(x,N);n=0:N-1;subplot(3,1,2);stem(n,fftshift(abs(y1),r,LineWidth,1.3);hold on;plot(n,fftshift(abs(y1),c-);title(FFTx2(n) : N=8);N=16;y2=fft(x,N);n=0:N-1;subplot(3,1,3);stem(n,fftshift(ab

14、s(y2),m,LineWidth,1.3);hold on;plot(n,fftshift(abs(y2),g-);title(FFTx2(n) : N=16);对x3(n)进行(jnxng)FFT变换(N=8和N=16)function output_args = Untitled3( input_args )%UNTITLED3 Summary of this function goes here% Detailed explanation goes hereclear all;x=4,3,2,1,1,2,3,4;N=8;n=0:N-1;subplot(3,1,1);stem(n,abs

15、(x),k,LineWidth,1.3);title(x3(n) 时间(shjin)序列);N=8;y1=fft(x,N);n=0:N-1;subplot(3,1,2);stem(n,fftshift(abs(y1),r,LineWidth,1.3);hold on;plot(n,fftshift(abs(y1),c-);title(FFTx3(n) : N=8);N=16;y2=fft(x,N);n=0:N-1;subplot(3,1,3);stem(n,fftshift(abs(y2),m,LineWidth,1.3);hold on;plot(n,fftshift(abs(y2),g-)

16、;title(FFTx3(n) : N=16);4.对x4(n)进行(jnxng)FFT变换(N=8和N=16)function output_args = Untitled3( input_args )%UNTITLED3 Summary of this function goes here% Detailed explanation goes hereclear all;n=0:15;%读入长度(chngd)x=cos(pi/4*n);subplot(3,1,1);stem(n,abs(x),k,LineWidth,1.3);title(x4(n) 时间(shjin)序列);N=8;y1=

17、fft(x,N);n=0:N-1;subplot(3,1,2);stem(n,fftshift(abs(y1),r,LineWidth,1.3);hold on;plot(n,fftshift(abs(y1),c-);title(FFTx4(n) : N=8);N=16;y2=fft(x,N);n=0:N-1;subplot(3,1,3);stem(n,fftshift(abs(y2),m,LineWidth,1.3);hold on;plot(n,fftshift(abs(y2),g-);title(FFTx4(n) : N=16);5.对x5(n)进行(jnxng)FFT变换(N=8和N=

18、16)function output_args = Untitled3( input_args )%UNTITLED3 Summary of this function goes here% Detailed explanation goes hereclear all;n=0:15;%读入长度x=sin(pi/8*n);subplot(3,1,1);stem(n,abs(x),k,LineWidth,1.3);title(x5(n) 时间序列);N=8;y1=fft(x,N);n=0:N-1;subplot(3,1,2);stem(n,fftshift(abs(y1),r,LineWidth

19、,1.3);hold on;plot(n,fftshift(abs(y1),c-);title(FFTx5(n) : N=8);N=16;y2=fft(x,N);n=0:N-1;subplot(3,1,3);stem(n,fftshift(abs(y2),m,LineWidth,1.3);hold on;plot(n,fftshift(abs(y2),g-);title(FFTx5(n) : N=16);6.对x6(n)进行(jnxng)FFT变换(N=16、N=32和N=64)function output_args = Untitled3( input_args )%UNTITLED3 S

20、ummary of this function goes here% Detailed explanation goes hereclear all;n=0:64;%读入长度(chngd)x=cos(pi*8/64*n)+cos(pi*16/64*n)+cos(pi*20/64*n);subplot(4,1,1);stem(n,abs(x),k,LineWidth,1.3);%plot(n,abs(x),b);title(x6(t)抽样(chu yn)得x6(n);N=16;y1=fft(x,N);n=0:N-1;subplot(4,1,2);stem(n,fftshift(abs(y1),r

21、,LineWidth,1.3);hold on;plot(n,fftshift(abs(y1),y-);title(FFTx6(n) : N=16);N=32;y2=fft(x,N);n=0:N-1;subplot(4,1,3);stem(n,fftshift(abs(y2),m,LineWidth,1.3);hold on;plot(n,fftshift(abs(y2),c-);title(FFTx6(n) : N=32);N=64;y3=fft(x,N);n=0:N-1;subplot(4,1,4);stem(n,fftshift(abs(y3),b,LineWidth,1.3);hold

22、 on;plot(n,fftshift(abs(y3),g-);title(FFTx6(n) : N=64);7.对x(n)=x4(n)+x5(n)进行FFT变换(N=8和N=16)function output_args = Untitled2( input_args )%UNTITLED2 Summary of this function goes here% Detailed explanation goes hereclear all;n=0:15x4=cos(pi/4*n);x5=sin(pi/8*n);x=x4+x5;subplot(3,1,1);stem(n,abs(x);hol

23、d on;plot(n,abs(x),y-);title(cos(pi/4*n)+sin(pi/8*n)时间(shjin)序列);N=8;y1=fft(x,N);n=0:N-1;subplot(3,1,2);stem(n,fftshift(abs(y1),m);hold on;plot(n,fftshift(abs(y1),c-);title(FFTx4+x5 : N=8);N=16;y2=fft(x,N);n=0:N-1;subplot(3,1,3);stem(n,fftshift(abs(y2),r);hold on;plot(n,fftshift(abs(y2),g-);title(FF

24、Tx4+x5 : N=16);8.对x(n)=x4(n)+jx5(n)进行(jnxng)FFT变换(N=8和N=16)function output_args = Untitled2( input_args )%UNTITLED2 Summary of this function goes here% Detailed explanation goes hereclear all;n=0:15x4=cos(pi/4*n);x5=j*sin(pi/8*n);x=x4+x5;subplot(3,1,1);stem(n,abs(x);hold on;plot(n,abs(x),y-);title(c

25、os(pi/4*n)+jsin(pi/8*n)时间(shjin)序列);N=8;y1=fft(x,N);n=0:N-1;subplot(3,1,2);stem(n,fftshift(abs(y1),m);hold on;plot(n,fftshift(abs(y1),c-);title(FFTx4+x5 : N=8);N=16;y2=fft(x,N);n=0:N-1;subplot(3,1,3);stem(n,fftshift(abs(y2),r);hold on;plot(n,fftshift(abs(y2),g-);title(FFTx4+x5 : N=16);9.GUI设计源程序func

26、tion varargout = untitled3(varargin)% UNTITLED3 M-file for untitled3.fig% UNTITLED3, by itself, creates a new UNTITLED3 or raises the existing% singleton*.% H = UNTITLED3 returns the handle to a new UNTITLED3 or the handle to% the existing singleton*.% UNTITLED3(CALLBACK,hObject,eventData,handles,.)

27、 calls the local% function named CALLBACK in UNTITLED3.M with the given input arguments.% UNTITLED3(Property,Value,.) creates a new UNTITLED3 or raises the% existing singleton*. Starting from the left, property value pairs are% applied to the GUI before untitled3_OpeningFunction gets called. An% unr

28、ecognized property name or invalid value makes property application% stop. All inputs are passed to untitled3_OpeningFcn via varargin.% *See GUI Options on GUIDEs Tools menu. Choose GUI allows only one% instance to run (singleton).% See also: GUIDE, GUIDATA, GUIHANDLES% Copyright 2002-2003 The MathW

29、orks, Inc.% Edit the above text to modify the response to help untitled3% Last Modified by GUIDE v2.5 23-Nov-2014 11:53:18% Begin initialization code - DO NOT EDITgui_Singleton = 1;gui_State = struct(gui_Name, mfilename, . gui_Singleton, gui_Singleton, . gui_OpeningFcn, untitled3_OpeningFcn, . gui_O

30、utputFcn, untitled3_OutputFcn, . gui_LayoutFcn, , . gui_Callback, );if nargin & ischar(varargin1) gui_State.gui_Callback = str2func(varargin1);endif nargout varargout1:nargout = gui_mainfcn(gui_State, varargin:);else gui_mainfcn(gui_State, varargin:);end% End initialization code - DO NOT EDIT% Execu

31、tes just before untitled3 is made visible.function untitled3_OpeningFcn(hObject, eventdata, handles, varargin)% This function has no output args, see OutputFcn.% hObject handle to figure% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (

32、see GUIDATA)% varargin command line arguments to untitled3 (see VARARGIN)% Choose default command line output for untitled3handles.output = hObject;% Update handles structureguidata(hObject, handles);% UIWAIT makes untitled3 wait for user response (see UIRESUME)% uiwait(handles.figure1);% Outputs fr

33、om this function are returned to the command line.function varargout = untitled3_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT);% hObject handle to figure% eventdata reserved - to be defined in a future version of MATLAB% handles structure wit

34、h handles and user data (see GUIDATA)% Get default command line output from handles structurevarargout1 = handles.output;function editn_Callback(hObject, eventdata, handles)% hObject handle to editn (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with

35、handles and user data (see GUIDATA)% Hints: get(hObject,String) returns contents of editn as text% str2double(get(hObject,String) returns contents of editn as a double% Executes during object creation, after setting all properties.function editn_CreateFcn(hObject, eventdata, handles)% hObject handle

36、 to editn (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called% Hint: edit controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc set(hObject,BackgroundColor,white);else set(hO

37、bject,BackgroundColor,get(0,defaultUicontrolBackgroundColor);endfunction editx_Callback(hObject, eventdata, handles)% hObject handle to editx (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hints: get(hObject,S

38、tring) returns contents of editx as text% str2double(get(hObject,String) returns contents of editx as a double% Executes during object creation, after setting all properties.function editx_CreateFcn(hObject, eventdata, handles)% hObject handle to editx (see GCBO)% eventdata reserved - to be defined

39、in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called% Hint: edit controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc set(hObject,BackgroundColor,white);else set(hObject,BackgroundColor,get(0,defaultUicontrolBackgroundCol

40、or);endfunction editn1_Callback(hObject, eventdata, handles)% hObject handle to editn1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hints: get(hObject,String) returns contents of editn1 as text% str2double(g

41、et(hObject,String) returns contents of editn1 as a double% Executes during object creation, after setting all properties.function editn1_CreateFcn(hObject, eventdata, handles)% hObject handle to editn1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - hand

42、les not created until after all CreateFcns called% Hint: edit controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc set(hObject,BackgroundColor,white);else set(hObject,BackgroundColor,get(0,defaultUicontrolBackgroundColor);endfunction editn2_Callback(hObject, eventdata,

43、 handles)% hObject handle to editn2 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hints: get(hObject,String) returns contents of editn2 as text% str2double(get(hObject,String) returns contents of editn2 as a

44、double% Executes during object creation, after setting all properties.function editn2_CreateFcn(hObject, eventdata, handles)% hObject handle to editn2 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called%

45、Hint: edit controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc set(hObject,BackgroundColor,white);else set(hObject,BackgroundColor,get(0,defaultUicontrolBackgroundColor);end% Executes on button press in pushbutton1.function pushbutton1_Callback(hObject, eventdata, handles)% hObject handle to pushbutton1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handl

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论