已阅读5页,还剩10页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
数字信号处理实验实验八:音频频谱分析仪设计与实现班级:20130831 姓名: 王彦臣学号: 2013064122指导老师: 栾晓明 2010年11月二实验内容function varargout = untitled(varargin)gui_Singleton = 1;gui_State = struct(gui_Name, mfilename, . gui_Singleton, gui_Singleton, . gui_OpeningFcn, untitled_OpeningFcn, . gui_OutputFcn, untitled_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:);endfunction untitled_OpeningFcn(hObject, eventdata, handles, varargin)handles.inputtype=0;xlabel(handles.plot1,freqency(Hz);xlabel(handles.plot2,freqency(Hz);xlabel(handles.plot3,freqency(Hz);xlabel(handles.plot4,freqency(Hz);xlabel(handles.plot5,freqency(Hz);ylabel(handles.plot1,amplitude);ylabel(handles.plot2,phase(rad);ylabel(handles.plot3,real);ylabel(handles.plot4,Imaginary);ylabel(handles.plot5,power);handles.output = hObject;guidata(hObject, handles);function varargout = untitled_OutputFcn(hObject, eventdata, handles) varargout1 = handles.output;function sampledpoint_Callback(hObject, eventdata, handles)function sampledpoint_CreateFcn(hObject, eventdata, handles)if ispc set(hObject,BackgroundColor,white);else set(hObject,BackgroundColor,get(0,defaultUicontrolBackgroundColor);endfunction edit1_CreateFcn(hObject, eventdata, handles)function edit2_CreateFcn(hObject, eventdata, handles)function fs_Callback(hObject, eventdata, handles)function fs_CreateFcn(hObject, eventdata, handles)if ispc set(hObject,BackgroundColor,white);else set(hObject,BackgroundColor,get(0,defaultUicontrolBackgroundColor);endfunction soundcard_Callback(hObject, eventdata, handles)set(findobj(Tag,recordtime),enable,on);h=findobj(Tag,filename);set(h,enable,off);h=findobj(Tag,freq);set(h,enable,off);h=findobj(Tag,amp);set(h,enable,off);h=findobj(Tag,phase);set(h,enable,off);set(handles.channel,enable,off);set(handles.fileopen,enable,off);set(handles.gensig,enable,off);set(handles.wavetype,enable,off);set(handles.add,enable,off);set(handles.startrecord,enable,on);set(handles.soundcard,value,1);set(handles.WAVfile,value,0);set(handles.generator,value,0);function WAVfile_Callback(hObject, eventdata, handles)h=findobj(Tag,filename);set(h,enable,on);h=findobj(Tag,freq);set(h,enable,off);h=findobj(Tag,amp);set(h,enable,off);h=findobj(Tag,phase);set(h,enable,off);set(findobj(Tag,recordtime),enable,off);set(handles.channel,enable,on);set(handles.fileopen,enable,on);set(handles.gensig,enable,off);set(handles.wavetype,enable,off);set(handles.add,enable,off);set(handles.startrecord,enable,off)set(handles.soundcard,value,0);set(handles.WAVfile,value,1);set(handles.generator,value,0);function generator_Callback(hObject, eventdata, handles)h=findobj(Tag,filename);set(h,enable,off);h=findobj(Tag,freq);set(h,enable,on);h=findobj(Tag,amp);set(h,enable,on);h=findobj(Tag,phase);set(h,enable,on);set(findobj(Tag,recordtime),enable,off);set(handles.channel,enable,off);set(handles.fileopen,enable,off);set(handles.gensig,enable,on);set(handles.wavetype,enable,on);set(handles.add,enable,on);set(handles.startrecord,enable,off);set(handles.soundcard,value,0);set(handles.WAVfile,value,0);set(handles.generator,value,1);function popupmenu2_Callback(hObject, eventdata, handles)function popupmenu2_CreateFcn(hObject, eventdata, handles)if ispc & isequal(get(hObject,BackgroundColor), get(0,defaultUicontrolBackgroundColor) set(hObject,BackgroundColor,white);endfunction recordtime_Callback(hObject, eventdata, handles)function recordtime_CreateFcn(hObject, eventdata, handles)if ispc set(hObject,BackgroundColor,white);else set(hObject,BackgroundColor,get(0,defaultUicontrolBackgroundColor);endfunction startrecord_Callback(hObject, eventdata, handles)Fs=str2double(get(findobj(Tag,fs),String);handles.y=wavrecord(str2double(get(findobj(Tag,recordtime),String)*Fs, Fs,int16);handles.inputtype=1;guidata(hObject,handles);plot(handles.time,handles.y);title(WAVE);ysize=size(handles.y)set(handles.sampledpoint,String,num2str(ysize(1);function filename_Callback(hObject, eventdata, handles)function filename_CreateFcn(hObject, eventdata, handles)if ispc set(hObject,BackgroundColor,white);else set(hObject,BackgroundColor,get(0,defaultUicontrolBackgroundColor);endfunction wavetype_Callback(hObject, eventdata, handles)function wavetype_CreateFcn(hObject, eventdata, handles)if ispc set(hObject,BackgroundColor,white);else set(hObject,BackgroundColor,get(0,defaultUicontrolBackgroundColor);endfunction channel_Callback(hObject, eventdata, handles)function channel_CreateFcn(hObject, eventdata, handles)if ispc set(hObject,BackgroundColor,white);else set(hObject,BackgroundColor,get(0,defaultUicontrolBackgroundColor);endfunction fileopen_Callback(hObject, eventdata, handles)temp = wavread(get(findobj(Tag,filename),String);channel=str2double(get(handles.channel,String);handles.y=temp(:,channel);handles.inputtype=2;guidata(hObject,handles);plot(handles.time,handles.y);title(WAVE);ysize=size(handles.y)set(handles.sampledpoint,String,num2str(ysize(1);function gensig_Callback(hObject, eventdata, handles)Fs=str2double(get(findobj(Tag,fs),String);N=str2double(get(findobj(Tag,sampledpoint),String);x=linspace(0,N/Fs,N);soundtype=get(handles.wavetype,Value);frequency=str2double(get(handles.freq,String);amp=str2double(get(handles.amp,String);phase=str2double(get(handles.phase,String);switch soundtype case 1 y=amp*sin(2*pi*x*frequency+phase); case 2 y=amp*sign(sin(2*pi*x*frequency+phase); case 3 y=amp*sawtooth(2*pi*x*frequency+phase,0.5); case 4 y=amp*sawtooth(2*pi*x*frequency+phase); case 5 y=amp*(2*rand(size(x)-1); otherwise errordlg(Illegal wave type,Choose errer);endif get(handles.add,Value)=0.0 handles.y=y;else handles.y=handles.y+y;endhandles.inputtype=3;guidata(hObject,handles);plot(handles.time,handles.y);title(handles.time,波形);xlabel(handles.time,时间);ylabel(handles.time,幅度);axis(0 N -str2double(get(handles.amp,String) str2double(get(handles.amp,String);function add_Callback(hObject, eventdata, handles)function add_DeleteFcn(hObject, eventdata, handles)function freq_Callback(hObject, eventdata, handles)function freq_CreateFcn(hObject, eventdata, handles)if ispc set(hObject,BackgroundColor,white);else set(hObject,BackgroundColor,get(0,defaultUicontrolBackgroundColor);endfunction amp_Callback(hObject, eventdata, handles)function amp_CreateFcn(hObject, eventdata, handles)if ispc set(hObject,BackgroundColor,white);else set(hObject,BackgroundColor,get(0,defaultUicontrolBackgroundColor);endfunction phase_Callback(hObject, eventdata, handles)function phase_CreateFcn(hObject, eventdata, handles)if ispc set(hObject,BackgroundColor,white);else set(hObject,BackgroundColor,get(0,defaultUicontrolBackgroundColor);endfunction pointfrom_Callback(hObject, eventdata, handles)function pointfrom_CreateFcn(hObject, eventdata, handles)if ispc set(hObject,BackgroundColor,white);else set(hObject,BackgroundColor,get(0,defaultUicontrolBackgroundColor);endfunction pointto_Callback(hObject, eventdata, handles)function pointto_CreateFcn(hObject, eventdata, handles)if ispc set(hObject,BackgroundColor,white);else set(hObject,BackgroundColor,get(0,defaultUicontrolBackgroundColor);endfunction analyseall_Callback(hObject, eventdata, handles)if get(hObject,Value)=0.0 set(handles.pointfrom,Enable,on); set(handles.pointto,Enable,on);else set(handles.pointfrom,String,1,Enable,off); set(handles.pointto,String,get(handles.sampledpoint,String),Enable,off);endfunction circle_Callback(hObject, eventdata, handles)function circle_CreateFcn(hObject, eventdata, handles)if ispc set(hObject,BackgroundColor,white);else set(hObject,BackgroundColor,get(0,defaultUicontrolBackgroundColor);endfunction outfreq_Callback(hObject, eventdata, handles)function outfreq_CreateFcn(hObject, eventdata, handles)if ispc set(hObject,BackgroundColor,white);else set(hObject,BackgroundColor,get(0,defaultUicontrolBackgroundColor);endfunction outamp_Callback(hObject, eventdata, handles)function outamp_CreateFcn(hObject, eventdata, handles)if ispc set(hObject,BackgroundColor,white);else set(hObject,BackgroundColor,get(0,defaultUicontrolBackgroundColor);endfunction outphase_Callback(hObject, eventdata, handles)function outphase_CreateFcn(hObject, eventdata, handles)if ispc set(hObject,BackgroundColor,white);else set(hObject,BackgroundColor,get(0,defaultUicontrolBackgroundColor);endfunction outpeak_Callback(hObject, eventdata, handles)function outpeak_CreateFcn(hObject, eventdata, handles)if ispc set(hObject,BackgroundColor,white);else set(hObject,BackgroundColor,get(0,defaultUicontrolBackgroundColor);endfunction outmean_Callback(hObject, eventdata, handles)function outmean_CreateFcn(hObject, eventdata, handles)if ispc set(hObject,BackgroundColor,white);else set(hObject,BackgroundColor,get(0,defaultUicontrolBackgroundColor);endfunction outmeansquare_Callback(hObject, eventdata, handles)function outmeansquare_CreateFcn(hObject, eventdata, handles)if ispc set(hObject,BackgroundColor,white);else set(hObject,BackgroundColor,get(0,defaultUicontrolBackgroundColor);endfunction outminus_Callback(hObject, eventdata, handles)function outminus_CreateFcn(hObject, eventdata, handles)if ispc set(hObject,BackgroundColor,white);else set(hObject,BackgroundColor,get(0,defaultUicontrolBackgroundColor);endfunction play_Callback(hObject, eventdata, handles)Fs=str2double(get(findobj(Tag,fs),String);wavplay(handles.y,Fs);function figure1_CreateFcn(hObject, eventdata, handles)function timeanalyse_Callback(hObject, eventdata, handles)Fs=str2double(get(findobj(Tag,fs),String);N=str2double(get(findobj(Tag,sampledpoint),String);if handles.inputtype=0 msgbox(No wave exist! Please choose a input type!); return;endn=1;ymax=max(handles.y(1) handles.y(2);ymin=min(handles.y(1) handles.y(2);from=str2double(get(handles.pointfrom,String);to=str2double(get(handles.pointto,String);if from1 | to-from5; msgbox(Error range!); return;endfor i=from+2:to-1; if handles.y(i-1)0 & handles.y(i-2)=0 & handles.y(i+1)0 if handles.y(i)=0 ti(n)=i; else ti(n)=i-handles.y(i)/(handles.y(i)-handles.y(i-1); end amp(n)=(ymax-ymin)/2; ymax=0;ymin=0; n=n+1; else if ymaxhandles.y(i) ymin=handles.y(i); end endendn=n-1;for i=1:n-1 T(i)=ti(i+1)-ti(i);endfreq=Fs/mean(T);set(handles.circle,String,1/freq);set(handles.outfreq,String,num2str(freq); set(handles.outamp,String,num2str(mean(amp(2:n-1);phase=2*pi*(1-(ti(1:n-1)-1)./T+floor(ti(1:n-1)-1)./T);set(handles.outphase,String,num2str(mean(phase);set(handles.outpeak,String,(max(handles.y(from:to)-min(handles.y(from:to)/2);set(handles.outmean,String,mean(handles.y(from:to);set(handles.outmeansquare,String,mean(handles.y(from:to).2);set(handles.outminus,String,std(handles.y(from:to)2);function frequencyanalyse_Callback(hObject, eventdata, handles)Fs=str2double(get(findobj(Tag,fs),String);N=str2double(get(findobj(Tag,sampledpoint),String);if handles.inputtype=0 msgbox(No wave exist! Please choose a input type!); return;endfrom=str2double(get(handles.pointfrom,String);to=str2double(get(handles.pointto,String);sample=handles.y(from:to);f=lins
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- (2026)国家开放大学电大专科《市场营销学》期末试题及答案
- 【高中语文】《声声慢(寻寻觅觅)》教案+统编版高一语文必修上册
- 部编人教版六年级上册语文第18课《只有一个地球》教案
- 2024年巴彦淖尔市磴口县社区工作者招聘真题
- 人教版(2024)六年级全一册信息科技第10课 开环控制应用广 教案
- 2025年许昌辅警协警招聘考试备考题库有完整答案详解
- 2025年海西州辅警招聘考试真题附答案详解
- 2025年贵阳辅警协警招聘考试真题及参考答案详解1套
- 2025年邯郸辅警协警招聘考试真题附答案详解(培优a卷)
- 2025年荆州辅警协警招聘考试备考题库及答案详解(名校卷)
- 2024-2025苏教版(2017)小学科学四年级上册期末考试测试卷及参考答案(共3套)
- 2024年广东高考物理试题分析和复习策略
- 中职学校学生量化考核规定
- 环境保护工作者个人自传范文
- 消毒供应专科护士培训与学习汇报
- 2025年人格权法的试题及答案
- 部编版八年级上册语文文言文总复习
- 建设工程造价管理协会工程造价纠纷调解手册
- Unit4EatWell(第3课时)SectionA3a-3d课件-人教版英语七年级下册
- 实施工程师述职报告
- 消防设施维护保养记录
评论
0/150
提交评论