北京理工大学数字信号处理实验报告程序.doc_第1页
北京理工大学数字信号处理实验报告程序.doc_第2页
北京理工大学数字信号处理实验报告程序.doc_第3页
北京理工大学数字信号处理实验报告程序.doc_第4页
北京理工大学数字信号处理实验报告程序.doc_第5页
已阅读5页,还剩13页未读 继续免费阅读

下载本文档

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

文档简介

数字信号处理实验报告一、 实验目的1. 深入掌握应用DFT分析信号的频谱的理论方法,针对该问题进行一次全面综合练习,完成一个完整的信号分析软件实现方法和流程,这种全面完整的综合练习可以帮助学生深入理解和消化基本理论,锻炼学生独立解决问题的能力,培养学生的创新意识,为今后的科研和工作打下良好的实践基础。2. 综合利用数字信号处理的理论知识完成数字滤波器的设计与实现,完成一个完整的数字滤波器设计软件的实现方法和流程。这种全面完整的综合练习可以帮助学生深入理解和消化基本理论,锻炼学生独立解决问题的能力,培养学生的创新意识,为今后的科研和工作打下良好的实践基础。二、 实验设备与环境计算机、MATLAB软件环境三、 实验内容1. 基于Matlab GUI的离散傅里叶变换分析2. 基于Matlab GUI的数字滤波器分析设计四、 实验结果1. 基于Matlab GUI的离散傅里叶变换分析信号:t=1:100;x=2*sin(t/25*2*pi)+5*sin(t/5*2*pi);说明:输入信号从Matlab Command Windows中生成,通过变量名导入本软件,并可输出DFT变换后的结果,默认名为DFT_输入变量名。2. 基于Matlab GUI的数字滤波器分析设计IIR 低通:(巴特沃兹)IIR高通:(切比雪夫I)IIR带通:(切比雪夫II)IIR带阻:(椭圆滤波器)FIR低通:(矩形窗)FIR高通:(汉宁窗)FIR带通:(布莱克曼窗)FIR带阻:(凯瑟窗)五、 程序界面设计及程序源代码1. 基于Matlab GUI的离散傅里叶变换分析界面设计:程序代码:function varargout = SignalDFTSoftware(varargin)% SIGNALDFTSOFTWARE MATLAB code for SignalDFTSoftware.fig% SIGNALDFTSOFTWARE, by itself, creates a new SIGNALDFTSOFTWARE or raises the existing% singleton*.% H = SIGNALDFTSOFTWARE returns the handle to a new SIGNALDFTSOFTWARE or the handle to% the existing singleton*.% SIGNALDFTSOFTWARE(CALLBACK,hObject,eventData,handles,.) calls the local% function named CALLBACK in SIGNALDFTSOFTWARE.M with the given input arguments.% SIGNALDFTSOFTWARE(Property,Value,.) creates a new SIGNALDFTSOFTWARE or raises the% existing singleton*. Starting from the left, property value pairs are% applied to the GUI before SignalDFTSoftware_OpeningFcn gets called. An% unrecognized property name or invalid value makes property application% stop. All inputs are passed to SignalDFTSoftware_OpeningFcn via varargin.% *See GUI Options on GUIDEs Tools menu. Choose GUI allows only one% instance to run (singleton).% See also: GUIDE, GUIDATA, GUIHANDLES % Edit the above text to modify the response to help SignalDFTSoftware % Last Modified by GUIDE v2.5 26-Nov-2011 12:55:11 % Begin initialization code - DO NOT EDITgui_Singleton = 1;gui_State = struct(gui_Name, mfilename, . gui_Singleton, gui_Singleton, . gui_OpeningFcn, SignalDFTSoftware_OpeningFcn, . gui_OutputFcn, SignalDFTSoftware_OutputFcn, . gui_LayoutFcn, , . gui_Callback, );if nargin & ischar(varargin1) gui_State.gui_Callback = str2func(varargin1);end if nargout varargout1:nargout = gui_mainfcn(gui_State, varargin:);else gui_mainfcn(gui_State, varargin:);end% End initialization code - DO NOT EDIT% - Executes just before SignalDFTSoftware is made visible.function SignalDFTSoftware_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% varargin command line arguments to SignalDFTSoftware (see VARARGIN) % Choose default command line output for SignalDFTSoftwarehandles.output = hObject; % Update handles structureguidata(hObject, handles); % UIWAIT makes SignalDFTSoftware wait for user response (see UIRESUME)% uiwait(handles.figure1);% - Outputs from this function are returned to the command line.function varargout = SignalDFTSoftware_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 % Get default command line output from handles structurevarargout1 = handles.output; % - If Enable = on, executes on mouse press in 5 pixel border.% - Otherwise, executes on mouse press in 5 pixel border or over random.function random_ButtonDownFcn(hObject, eventdata, handles)% hObject handle to random (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB % - Executes on button press in random.function random_Callback(hObject, eventdata, handles)% hObject handle to random (see GCBO)% eventdata reserved - to be defined in a future version of MATLABglobal x;global x_flag;x=rand(1,50)*20-10;x_flag=1;if(x_flag) plot(handles.TD,0:(length(x)-1),x);end % - Executes on button press in Delete.function Delete_Callback(hObject, eventdata, handles)% hObject handle to Delete (see GCBO)% eventdata reserved - to be defined in a future version of MATLABglobal x;global X;global x_flag;global X_flag;x=0;X=0;x_flag=0;X_flag=0;plot(handles.TD,0,0);plot(handles.FD,0,0); % - If Enable = on, executes on mouse press in 5 pixel border.% - Otherwise, executes on mouse press in 5 pixel border or over Delete.function Delete_ButtonDownFcn(hObject, eventdata, handles)% hObject handle to Delete (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% - If Enable = on, executes on mouse press in 5 pixel border.% - Otherwise, executes on mouse press in 5 pixel border or over Analyse.function Analyse_ButtonDownFcn(hObject, eventdata, handles)% hObject handle to Analyse (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB % - Executes on button press in Analyse.function Analyse_Callback(hObject, eventdata, handles)% hObject handle to Analyse (see GCBO)% eventdata reserved - to be defined in a future version of MATLABglobal x;global X;global x_flag;global X_flag;if(x_flag) X=fft(x); X_flag=1;endif(X_flag) stem(handles.FD,linspace(0,2*pi,length(X),abs(X); xlim(handles.FD,0,2*pi)end % - Executes on button press in Export.function Export_Callback(hObject, eventdata, handles)% hObject handle to Export (see GCBO)% eventdata reserved - to be defined in a future version of MATLABglobal X;global X_flag;if(X_flag) assignin(base,get(handles.edit4,String),X);end % - Executes during object creation, after setting all properties.function text1_CreateFcn(hObject, eventdata, handles)% hObject handle to text1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns calledglobal x_flag;global X_flag;global x;global X;x_flag=0;X_flag=0;x=0;X=0; function name_Callback(hObject, eventdata, handles)% hObject handle to name (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% Hints: get(hObject,String) returns contents of name as text% str2double(get(hObject,String) returns contents of name as a double% - Executes during object creation, after setting all properties.function name_CreateFcn(hObject, eventdata, handles)if ispc & isequal(get(hObject,BackgroundColor), get(0,defaultUicontrolBackgroundColor) set(hObject,BackgroundColor,white);end% - Executes on button press in import.function import_Callback(hObject, eventdata, handles)global x;global x_flag;global signal_name;signal_name=get(,String); x=empty;set(,String,Not exist,Retry!);x=evalin(base,signal_name);set(,String,Succeed);x_flag=1;if(x_flag) plot(handles.TD,0:(length(x)-1),x);endset(handles.edit4,String,strcat(DFT_,signal_name);function edit4_Callback(hObject, eventdata, handles)function edit4_CreateFcn(hObject, eventdata, handles)if ispc & isequal(get(hObject,BackgroundColor), get(0,defaultUicontrolBackgroundColor) set(hObject,BackgroundColor,white);endglobal signal_name;2. 基于Matlab GUI的数字滤波器分析设计界面设计:程序设计:function varargout = filter(varargin)%EDIT By Yu Yizhe%V1.0%2011/11/20%all right reserve% Begin initialization code - DO NOT EDITgui_Singleton = 1;gui_State = struct(gui_Name, mfilename, . gui_Singleton, gui_Singleton, . gui_OpeningFcn, filter_OpeningFcn, . gui_OutputFcn, filter_OutputFcn, . gui_LayoutFcn, , . gui_Callback, );if nargin & ischar(varargin1) gui_State.gui_Callback = str2func(varargin1);end if nargout varargout1:nargout = gui_mainfcn(gui_State, varargin:);else gui_mainfcn(gui_State, varargin:);end% End initialization code - DO NOT EDIT % - Executes just before filter is made visible.function filter_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% varargin unrecognized PropertyName/PropertyValue pairs from the% command line (see VARARGIN)% Choose default command line output for filterhandles.output = hObject; % Update handles structureguidata(hObject, handles); % UIWAIT makes filter wait for user response (see UIRESUME)% uiwait(handles.figure1); % - Outputs from this function are returned to the command line.function varargout = filter_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% Get default command line output from handles structurevarargout1 = handles.output; function text1_CreateFcn(hObject, eventdata, handles)global ch1;global ch2;global ch31;global ch32; ch1=1;ch2=1;ch31=1;ch32=1; function IIRtype_Callback(hObject, eventdata, handles)global ch1;global ch2;global ch31;global ch32;ch31=get(hObject,Value);function IIRtype_CreateFcn(hObject, eventdata, handles)if ispc & isequal(get(hObject,BackgroundColor), get(0,defaultUicontrolBackgroundColor) set(hObject,BackgroundColor,white);end function e11_Callback(hObject, eventdata, handles)function e11_CreateFcn(hObject, eventdata, handles)if ispc & isequal(get(hObject,BackgroundColor), get(0,defaultUicontrolBackgroundColor) set(hObject,BackgroundColor,white);end function e12_Callback(hObject, eventdata, handles)function e12_CreateFcn(hObject, eventdata, handles)if ispc & isequal(get(hObject,BackgroundColor), get(0,defaultUicontrolBackgroundColor) set(hObject,BackgroundColor,white);endfunction e21_Callback(hObject, eventdata, handles)function e21_CreateFcn(hObject, eventdata, handles)if ispc & isequal(get(hObject,BackgroundColor), get(0,defaultUicontrolBackgroundColor) set(hObject,BackgroundColor,white);end function e22_Callback(hObject, eventdata, handles)function e22_CreateFcn(hObject, eventdata, handles)if ispc & isequal(get(hObject,BackgroundColor), get(0,defaultUicontrolBackgroundColor) set(hObject,BackgroundColor,white);end function e31_Callback(hObject, eventdata, handles)function e31_CreateFcn(hObject, eventdata, handles)if ispc & isequal(get(hObject,BackgroundColor), get(0,defaultUicontrolBackgroundColor) set(hObject,BackgroundColor,white);end function e32_Callback(hObject, eventdata, handles)function e32_CreateFcn(hObject, eventdata, handles)if ispc & isequal(get(hObject,BackgroundColor), get(0,defaultUicontrolBackgroundColor) set(hObject,BackgroundColor,white);end function e41_Callback(hObject, eventdata, handles)function e41_CreateFcn(hObject, eventdata, handles)if ispc & isequal(get(hObject,BackgroundColor), get(0,defaultUicontrolBackgroundColor) set(hObject,BackgroundColor,white);end function e42_Callback(hObject, eventdata, handles)function e42_CreateFcn(hObject, eventdata, handles)if ispc & isequal(get(hObject,BackgroundColor), get(0,defaultUicontrolBackgroundColor) set(hObject,BackgroundColor,white);end function generate_Callback(hObject, eventdata, handles)global ch1;global ch2;global ch31;global ch32;global typech;global w1p;global w1s;global w2p;global w2s;global rp;global rs; if ch1=1 typech=ch1*100+ch2*10+ch31;elseif ch2=2 typech=ch1*100+ch2*10+ch32;end w1p=str2num(get(handles.e11,String);w1s=str2num(get(handles.e12,String);w2p=str2num(get(handles.e21,String);w2s=str2num(get(handles.e22,String);rp=str2num(get(handles.e41,String);rs=str2num(get(handles.e42,String);Generate(handles); function FIRtype_Callback(hObject, eventdata, handles)global ch1;global ch2;global ch31;global ch32;ch32=get(hObject,Value);function FIRtype_CreateFcn(hObject, eventdata, handles)if ispc & isequal(get(hObject,BackgroundColor), get(0,defaultUicontrolBackgroundColor) set(hObject,BackgroundColor,white);end function poptype_Callback(hObject, eventdata, handles)global ch1;global ch2;global ch31;global ch32;ch2=get(hObject,Value);reprint(handles);function poptype_CreateFcn(hObject, eventdata, handles)if ispc & isequal(get(hObject,BackgroundColor), get(0,defaultUicontrolBackgroundColor) set(hObject,BackgroundColor,white);end function iirchoose_ButtonDownFcn(hObject, eventdata, handles)function firchoose_Callback(hObject, eventdata, handles)global ch1;global ch2;global ch31;global ch32;if(get(handles.firchoose,Value)=0) set(handles.iirchoose,Value,1); set(handles.FIRtype,Visible,off); set(handles.IIRtype,Visible,on); ch1=1;endif(get(handles.firchoose,Value)=1) set(handles.iirchoose,Value,0); set(handles.FIRtype,Visible,on); set(handles.IIRtype,Visible,off); ch1=2;endreprint(handles); function firchoose_ButtonDownFcn(hObject, eventdata, handles)function iirchoose_Callback(hObject, eventdata, handles)global ch1;global ch2;global ch31;global ch32;if(get(handles.iirchoose,Value)=0) set(handles.firchoose,Value,1); set(handles.FIRtype,Visible,on); set(handles.IIRtype,Visible,off); ch1=2;endif(get(handles.iirchoose,Value)=1) set(handles.firchoose,Value,0); set(handles.FIRtype,Visible,off); set(handles.IIRtype,Visible,on); ch1=1;endreprint(handles); function reprint(handles)global ch1;global ch2;global ch31;global ch32; temp=ch1*10+ch2;tempswitch temp case 11,12 set(handles.add1,Visible,off); set(handles.add2,Visible,off); set(handles.e21,Visible,off); set(handles.e22,Visible,off); set(handles.pr,Visible,on); case13,14 set(handles.add1,Visible,on); set(handles.add2,Visible,on); set(handles.e21,Visible,on); set(handles.e22,Visible,on); set(handles.pr,Visible,on); case21,22, set(handles.add1,Visible,off); set(handles.add2,Visible,off); set(handles.e21,Visible,off); set(handles.e22,Visible,off); case23,24, set(handles.add1,Visible,on); set(handles.add2,Visible,on); set(handles.e21,Visible,on); set(handles.e22,Visible,on); otherwise fprintf(switch errorn);end function Generate(handles)global ch1;global ch2;global ch31;global ch32;global typech;global w1p;global w1s;global w2p;global w2s;global rp;global rs;N=0;Wn=0;Wp=0;Wst=0;Rp=0;As=0;ftype=a;b=0;a=0;switch ch2 case 1, ftype=low; case 2, ftype=high; case 3, ftype=bandpass; case 4, ftype=stop;end switch ch2 case 1,2 Wp=w1p; Wst=w1s; Rp=rp; As=rs; case 3,4 Wp=w2p w1p; Wst=w2s w1s; Rp=rp; As=rs; end switch ch1 %IIR case 1, switch ch31 case 1, N,Wn=buttord(Wp,Wst,Rp,As); b,a=butter(N,Wn,ftype); case 2, N,Wn=cheb1ord(Wp,Wst,Rp,As); b,a=cheby1(N,Rp,Wn,ftype); case 3, N,Wn=cheb2ord(Wp,Wst,Rp,As); b,a=cheby2(N,As,Wn,ftype); case 4, N,Wn=ellipord(Wp,Wst,Rp,As); b,a=ellip(N,Rp,As,Wn,ftype); end print4(a,b,handles); case 2 %FIR tranbw=0; N=0; hw=0; Wn=(Wp+Wst)/2; switch ch32 case 1, %Rectangular tranbw=1.8; N=ceil(tranbw/abs(w1s-w1p)+1; hw=boxcar(N); case 2, %Hanning tranbw=6.2; N=ceil(tranbw/abs(w1s-w1p)+1; hw=hanning(N); case 3, %Hamming tranbw=6.6; N=ceil(tranbw/abs(w1s-w1p)+1; hw=hamming(N); case 4, %Blackman tranbw=11; N=ceil(tranbw/abs(w1s-w1p)+1; hw=

温馨提示

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

评论

0/150

提交评论