数字信号处理综合实验.docx
《数字信号处理综合实验.docx》由会员分享,可在线阅读,更多相关《数字信号处理综合实验.docx(13页珍藏版)》请在冰豆网上搜索。
数字信号处理综合实验
北京科技大学
《信号系统与信号处理》实验报告
学院:
计算机与通信工程学院
班级:
通信1303
学号:
41356071
姓名:
李成钢
实验成绩:
________________________
2016年1月14日
语音信号处理
一、实验目的
借助基础实验篇编制的程序,对语音信号进行处理。
通过综合实验篇,使得学生能够充分了解信号处理及数字信号处理的过程;使得学生能够对自己设计的频谱分析程序与滤波器程序得到灵活的应用;使得学生能够综合分析信号处理过程各个阶段信号时域与频域特性。
二、实验内容
1、录制一段各人自己的语音信号。
2、对录制的信号进行采样;画出采样后语音信号的时域波形和频谱图;
3、给定滤波器的性能指标,采用窗函数法或双线性变换设计滤波器,并画出滤波器的频率响
三、实验要求
1、完成实验内容要求的各项内容。
写明设计思路及其设计原理;
2、给出MATLAB代码,并给编制的程序加注释;
3、给出仿真测试结果并对测试结果进行分析;
4、对设计成果做出评价,说明本设计的特点和存在问题,提出改进设计意见;
实验程序:
([0,1,-pi,pi]);
functionvarargout=untitled1(varargin)
%UNTITLED1M-fileforuntitled1.fig
%UNTITLED1,byitself,createsanewUNTITLED1orraisestheexisting
%singleton*.
%
%H=UNTITLED1returnsthehandletoanewUNTITLED1orthehandleto
%theexistingsingleton*.
%
%UNTITLED1('CALLBACK',hObject,eventData,handles,...)callsthelocal
%functionnamedCALLBACKinUNTITLED1.Mwiththegiveninputarguments.
%
%UNTITLED1('Property','Value',...)createsanewUNTITLED1orraisesthe
%existingsingleton*.Startingfromtheleft,propertyvaluepairsare
%appliedtotheGUIbeforeuntitled1_OpeningFunctiongetscalled.An
%unrecognizedpropertynameorinvalidvaluemakespropertyapplication
%stop.Allinputsarepassedtountitled1_OpeningFcnviavarargin.
%
%*SeeGUIOptionsonGUIDE'sToolsmenu.Choose"GUIallowsonlyone
%instancetorun(singleton)".
%
%Seealso:
GUIDE,GUIDATA,GUIHANDLES
%Edittheabovetexttomodifytheresponsetohelpuntitled1
%LastModifiedbyGUIDEv2.524-Oct-201222:
23:
01
%Begininitializationcode-DONOTEDIT
gui_Singleton=1;
gui_State=struct('gui_Name',mfilename,...
'gui_Singleton',gui_Singleton,...
'gui_OpeningFcn',@untitled1_OpeningFcn,...
'gui_OutputFcn',@untitled1_OutputFcn,...
'gui_LayoutFcn',[],...
'gui_Callback',[]);
ifnargin&isstr(varargin{1})
gui_State.gui_Callback=str2func(varargin{1});
end
ifnargout
[varargout{1:
nargout}]=gui_mainfcn(gui_State,varargin{:
});
else
gui_mainfcn(gui_State,varargin{:
});
end
%Endinitializationcode-DONOTEDIT
%---Executesjustbeforeuntitled1ismadevisible.
functionuntitled1_OpeningFcn(hObject,eventdata,handles,varargin)
%Thisfunctionhasnooutputargs,seeOutputFcn.
%hObjecthandletofigure
%eventdatareserved-tobedefinedinafutureversionofMATLAB
%handlesstructurewithhandlesanduserdata(seeGUIDATA)
%varargincommandlineargumentstountitled1(seeVARARGIN)
%Choosedefaultcommandlineoutputforuntitled1
handles.output=hObject;
%Updatehandlesstructure
guidata(hObject,handles);
%UIWAITmakesuntitled1waitforuserresponse(seeUIRESUME)
%uiwait(handles.figure1);
%---Outputsfromthisfunctionarereturnedtothecommandline.
functionvarargout=untitled1_OutputFcn(hObject,eventdata,handles)
%varargoutcellarrayforreturningoutputargs(seeVARARGOUT);
%hObjecthandletofigure
%eventdatareserved-tobedefinedinafutureversionofMATLAB
%handlesstructurewithhandlesanduserdata(seeGUIDATA)
%Getdefaultcommandlineoutputfromhandlesstructure
varargout{1}=handles.output;
%---Executesonbuttonpressinpushbutton1.
functionpushbutton1_Callback(hObject,eventdata,handles)
z1=wavread('d:
\wei.wav');
plot(z1);
sound(z1);
%hObjecthandletopushbutton1(seeGCBO)
%eventdatareserved-tobedefinedinafutureversionofMATLAB
%handlesstructurewithhandlesanduserdata(seeGUIDATA)
%---Executesonbuttonpressinpushbutton2.
functionpushbutton2_Callback(hObject,eventdata,handles)
z1=wavread('d:
\wei.wav');
y1=z1(1:
8192);
Y1=fft(y1);
n=0:
8191;
plot(n,Y1);
%hObjecthandletopushbutton2(seeGCBO)
%eventdatareserved-tobedefinedinafutureversionofMATLAB
%handlesstructurewithhandlesanduserdata(seeGUIDATA)
%---Executesonbuttonpressinpushbutton3.
functionpushbutton3_Callback(hObject,eventdata,handles)
clear;
globalfp;
globalfc;
[z1,fs,bits]=wavread('d:
\wei.wav')
y1=z1(1:
8192);
Y1=fft(y1);
As=100;Ap=1;Fs=8000;
wc=2*atan(fc/(2*Fs));wp=2*atan(fp/(2*Fs));
wdel=wc-wp;
beta=0.112*(As-8.7);
N=ceil((As-8)/2.285/wdel);
wn=kaiser(N+1,beta);
ws=(wp+wc)/2/pi;
b=fir1(N,ws,wn);
figure
(1);
freqz(b,1);
x=fftfilt(b,z1);
X=fft(x,8192);
figure
(2);
subplot(2,2,1);plot(abs(Y1));
%axis([0,1000,0,1.0]);
title('Â˲¨Ç°ÐźÅƵÆ×');
subplot(2,2,2);plot(abs(X));
%axis([0,1000,0,1.0]);
title('Â˲¨ºóÐźÅƵÆ×');
subplot(2,2,3);plot(z1);
title('Â˲¨Ç°ÐźŲ¨ÐÎ');
subplot(2,2,4);plot(x);
title('Â˲¨ºóÐźŲ¨ÐÎ');
sound(x,fs,bits);
%hObjecthandletopushbutton3(seeGCBO)
%eventdatareserved-tobedefinedinafutureversionofMATLAB
%handlesstructurewithhandlesanduserdata(seeGUIDATA)
%---Executesonbuttonpressinpushbutton4.
functionpushbutton4_Callback(hObject,eventdata,handles)
%hObjecthandletopushbutton4(seeGCBO)
%eventdatareserved-tobedefinedinafutureversionofMATLAB
%handlesstructurewithhandlesanduserdata(seeGUIDATA)
%---Executesduringobjectcreation,aftersettingallproperties.
functionedit1_CreateFcn(hObject,eventdata,handles)
%hObjecthandletoedit1(seeGCBO)
%eventdatareserved-tobedefinedinafutureversionofMATLAB
%handlesempty-handlesnotcreateduntilafterallCreateFcnscalled
%Hint:
editcontrolsusuallyhaveawhitebackgroundonWindows.
%SeeISPCandCOMPUTER.
ifispc
set(hObject,'BackgroundColor','white');
elseset(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
functionedit1_Callback(hObject,eventdata,handles)
globalfp;
get(hObject,'String');
fp=str2num(get(hObject,'String'));
%hObjecthandletoedit1(seeGCBO)
%eventdatareserved-tobedefinedinafutureversionofMATLAB
%handlesstructurewithhandlesanduserdata(seeGUIDATA)
%Hints:
get(hObject,'String')returnscontentsofedit1astext
%str2double(get(hObject,'String'))returnscontentsofedit1asadouble
%---Executesduringobjectcreation,aftersettingallproperties.
functionedit2_CreateFcn(hObject,eventdata,handles)
%hObjecthandletoedit2(seeGCBO)
%eventdatareserved-tobedefinedinafutureversionofMATLAB
%handlesempty-handlesnotcreateduntilafterallCreateFcnscalled
%Hint:
editcontrolsusuallyhaveawhitebackgroundonWindows.
%SeeISPCandCOMPUTER.
ifispc
set(hObject,'BackgroundColor','white');
elseset(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
functionedit2_Callback(hObject,eventdata,handles)
globalfc;
get(hObject,'String');
fc=str2num(get(hObject,'String'));
%hObjecthandletoedit2(seeGCBO)
%eventdatareserved-tobedefinedinafutureversionofMATLAB
%handlesstructurewithhandlesanduserdata(seeGUIDATA)
%Hints:
get(hObject,'String')returnscontentsofedit2astext
%str2double(get(hObject,'String'))returnscontentsofedit2asadouble
实验结果:
课本上的实验部分:
卷积
实验程序:
n=0:
30;
%输入x(n)和冲激响应h(n)
x=zeros(1,length(n));
h=zeros(1,length(n));
x([find((n>=0)&(n<=4))])=1;
h([find((n>=0)&(n<=8))])=0.5;
figure
(1)
subplot(3,1,1);
stem(n,x);
axis([0,30,0,2]);
title('输入序列');
xlabel('n');
ylabel('x(n)');
subplot(3,1,2);
stem(n,h);
axis([0,30,0,2]);
title('冲激响应序列');
xlabel('n');
ylabel('h(n)');
%输出响应
y=conv(x,h);
subplot(3,1,3);
n=0:
length(y)-1;
stem(n,y);
title('输出响应');
xlabel('n');
ylabel('y(n)');
实验结果:
实验总结:
数字信号处理课程的特点是课程本身理论性强、公式推导较多、概念比较抽象,枯燥难学.而实验淡化枯燥的数学推导,辅助以现代化学习手段,尽量将一些理论分析用图形手段展示出来,以增强了自己的感性认识。
实验课主要是以MATLAB为平台,充分利用MATLAB的数字信号处理工具箱提供的各种功能让自己亲自动手将课堂所学进行仿真实现。
通过这些仿真实验加深了自己对所学概念和知识的理解,加强运用到实际中的能力。
Matlab很强大,功能复杂,可以用在许多的方面。
但究其根本,首要任务要知道如何产生信号源,这必须要使用相关的数学知识和数学工具箱;其二,要懂得数字信号处理的基本知识和数字信号处理工具箱;其三,要知道如何输出仿真的结果。
总之,这次实验让自己受益匪浅。