大连理工大学实验报告学院(系):电信专业:电子信息工程班级:电子1204姓名:梁宇学号:201281001组:___实验时间:实验室:实验台:指导教师签字:成绩:实验四、含噪语音信号分析一、实验题目和代码1.实验界面设计2.实验源程序:functionvarargout=ly1(varargin)%LY1MATLABcodeforly1.fig%LY1,byitself,createsanewLY1orraisestheexisting%singleton*.%%H=LY1returnsthehandletoanewLY1orthehandleto%theexistingsingleton*.%%LY1('CALLBACK',hObject,eventData,handles,...)callsthelocal%functionnamedCALLBACKinLY1.Mwiththegiveninputarguments.%%LY1('Property','Value',...)createsanewLY1orraisesthe%existingsingleton*.Startingfromtheleft,propertyvaluepairsare%appliedtotheGUIbeforely1_OpeningFcngetscalled.An%unrecognizedpropertynameorinvalidvaluemakespropertyapplication%stop.Allinputsarepassedtoly1_OpeningFcnviavarargin.%%*SeeGUIOptionsonGUIDE'sToolsmenu.ChooseGUIallowsonlyone%instancetorun(singleton).%%Seealso:GUIDE,GUIDATA,GUIHANDLES%Edittheabovetexttomodifytheresponsetohelply1%LastModifiedbyGUIDEv2.504-Jun-201515:33:58%Begininitializationcode-DONOTEDITgui_Singleton=1;gui_State=struct('gui_Name',mfilename,...'gui_Singleton',gui_Singleton,...'gui_OpeningFcn',@ly1_OpeningFcn,...'gui_OutputFcn',@ly1_OutputFcn,...'gui_LayoutFcn',[],...'gui_Callback',[]);ifnargin&&ischar(varargin{1})gui_State.gui_Callback=str2func(varargin{1});endifnargout[varargout{1:nargout}]=gui_mainfcn(gui_State,varargin{:});elsegui_mainfcn(gui_State,varargin{:});end%Endinitializationcode-DONOTEDIT%---Executesjustbeforely1ismadevisible.functionly1_OpeningFcn(hObject,eventdata,handles,varargin)%Thisfunctionhasnooutputargs,seeOutputFcn.%hObjecthandletofigure%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)%varargincommandlineargumentstoly1(seeVARARGIN)%Choosedefaultcommandlineoutputforly1handles.output=hObject;%初始化全局变量fs=0;%采样频率f1=0;%通带截止频率1f2=0;%通带截止频率2f3=0;%阻带起始频率1f4=0;%阻带起始频率2data=0%采样数据存储%Updatehandlesstructureguidata(hObject,handles);%UIWAITmakesly1waitforuserresponse(seeUIRESUME)%uiwait(handles.figure1);%---Outputsfromthisfunctionarereturnedtothecommandline.functionvarargout=ly1_OutputFcn(hObject,eventdata,handles)%varargoutcellarrayforreturningoutputargs(seeVARARGOUT);%hObjecthandletofigure%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)%Getdefaultcommandlineoutputfromhandlesstructurevarargout{1}=handles.output;%---Executesonbuttonpressinpushbutton1.functionpushbutton1_Callback(hObject,eventdata,handles)%hObjecthandletopushbutton1(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)%读入一段音频文件globalfsglobaldata[filename,filepath]=uigetfile('.wav','选择音频文件');if(filename==0)return;endaudeofile=strcat(filepath,filename);[data,fs,handles.NBITS]=wavread(audeofile);globalfs%语音信号的时域输出t=0:1/fs:(length(data)-1)/fs;subplot(handles.axes1)plot(t,data);%语音信号的频域输出N=length(data);y=fft(data,N);f=(0:1:N-1)*fs/(N)-fs/2;subplot(handles.axes2)plot(f,fftshift(abs(y)));%---Executesonbuttonpressinpushbutton2.functionpushbutton2_Callback(hObject,eventdata,handles)%hObjecthandletopushbutton2(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)globalfsglobaldatasubplot(handles.axes4)t=0:1/fs:(length(data)-1)/fs;plot(t,data);axis([00.5-11])%语音信号频域输出N=length(data);Y=fft(data,N);f=(0:1:N-1)*fs/(N)-fs/2;subplot(handles.axes5)plot(f,fftshift(abs(Y)));functionedit1_Callback(hObject,eventdata,handles)%hObjecthandletoedit1(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)%Hints:get(hObject,'String')returnscontentsofedit1astext%str2double(get(hObject,'String'))returnscontentsofedit1asadouble%取输入框数据val=get(hObject,'String');globalf1f1=str2double(val);%---Executesduringobjectcreation,aftersettingallproperties.functionedit1_CreateFcn(hObject,eventdata,handles)%hObjecthandletoedit1(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesempty-handlesnotcreateduntilafterallCreateFcnscalled%Hint:editcontrolsusuallyhaveawhitebackgroundonWindows.%SeeISPCandCOMPUTER.ifispc&&isequal(get(hObject,'BackgroundColor'),get(0,'defaultUicontrolBackgroundColor'))set(hObject,'BackgroundColor','white');endfunctionedit2_Callback(hObject,eventdata,handles)%hObjecthandletoedit2(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)%Hints:get(hObject,'String')returnscontentsofedit2astext%str2double(get(hObject,'String'))returnscontentsofedit2asadoubleval=get(hObject,'String');globalf2f2=str2double(val);%---Executesduringobjectcreation,aftersettingallproperties.functionedit2_CreateFcn(hObject,eventdata,handles)%hObjecthandletoedit2(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesempty-handlesnotcreateduntilafterallCreateFcnscalled%Hint:editcontrolsusuallyhaveawhitebackgroundonWindows.%SeeISPCandCOMPUTER.ifispc&&isequal(get(hObject,'BackgroundColor'),get(0,'defaultUicontrolBackgroundColor'))set(hObject,'BackgroundColor','white');endfunctionedit3_