數(shù)字信號(hào)處理實(shí)驗(yàn)八_第1頁(yè)
數(shù)字信號(hào)處理實(shí)驗(yàn)八_第2頁(yè)
數(shù)字信號(hào)處理實(shí)驗(yàn)八_第3頁(yè)
數(shù)字信號(hào)處理實(shí)驗(yàn)八_第4頁(yè)
數(shù)字信號(hào)處理實(shí)驗(yàn)八_第5頁(yè)
已閱讀5頁(yè),還剩4頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

..實(shí)驗(yàn)八音頻頻譜分析儀設(shè)計(jì)與實(shí)現(xiàn)實(shí)驗(yàn)原理MATLAB是一個(gè)數(shù)據(jù)信息和處理功能十分強(qiáng)大的工程實(shí)用軟件,其數(shù)據(jù)采集工具箱為實(shí)現(xiàn)數(shù)據(jù)的輸入和輸出提供了十分方便的函數(shù)和命令。本實(shí)驗(yàn)要求基于聲卡與MATLAB實(shí)現(xiàn)音頻信號(hào)頻譜分析儀的設(shè)計(jì)原理與實(shí)現(xiàn),功能包括:信號(hào)的輸入,從聲卡輸入、從WAV文件輸入、從標(biāo)準(zhǔn)信號(hào)發(fā)生器輸入;信號(hào)的波形分析,包括幅值、頻率、周期、相位的估計(jì),以及統(tǒng)計(jì)量峰值、均值、均方值和方差的計(jì)算;信號(hào)頻譜分析,頻率、周期的估計(jì),圖形顯示幅值譜、相位譜、實(shí)頻譜、虛頻譜和功率譜的曲線。頻率〔周期檢測(cè)對(duì)周期信號(hào)來說,可以用時(shí)域波形分析來確定信號(hào)的周期,也就是計(jì)算相鄰的兩個(gè)信號(hào)波峰的時(shí)間差或過零點(diǎn)的時(shí)間差。這里采用過零點(diǎn)〔ti的時(shí)間差T〔周期。頻率即為f=1/T,由于能夠求得多個(gè)T值〔ti有多個(gè),故采用它們的平均值作為周期的估計(jì)值。幅值檢測(cè)在一個(gè)周期內(nèi),求出信號(hào)的最大值ymax與最小值ymin的差的一半,即A=〔ymax-ymin/2,除以第一個(gè)以外的A值的平均作為幅值的估計(jì)值。相位檢測(cè)采用過零法,即通過判斷與同頻零相位信號(hào)過零點(diǎn)時(shí)刻,計(jì)算其時(shí)間差,然后換成相應(yīng)的相位差。Fi=2pi<1-ti/T>,同樣,以fi的平均值作為相位的估計(jì)值。數(shù)字信號(hào)統(tǒng)計(jì)量估計(jì)峰值P的估計(jì)在樣本數(shù)據(jù)x中找出最大值與最小值,其差值為雙峰值,雙峰值的一半即為峰值。均值估計(jì)式中,N為樣本容量,下同。均方值估計(jì)方差估計(jì)頻譜分析原理是與分析只能反映信號(hào)的幅值隨時(shí)間的變化情況,除單位頻率分量的簡(jiǎn)單波形外,很難明確提示信號(hào)的頻率組成和個(gè)頻率分量的大小,而頻譜分析能很好的解決此問題。DFT與FFT對(duì)于給定的時(shí)域信號(hào)y,可以通過Foutier變換得到頻域信息Y。Y可按下式計(jì)算式中,N為樣本容量,t=1/Fs為采樣間隔。采樣信號(hào)的頻譜是一個(gè)連續(xù)的頻譜,不可能計(jì)算出所有的點(diǎn)的值,故采用離散傅立葉變換〔DFT,即式中,f=Fs/N。但上式的計(jì)算效率很低,因?yàn)橛写罅康闹笖?shù)〔等價(jià)于三角函數(shù)運(yùn)算,故實(shí)際中多采用快速傅立葉變換〔FFT。其原理是將重復(fù)的三角函數(shù)計(jì)算的中間結(jié)果保存起來,以減少重復(fù)三角函數(shù)計(jì)算帶來的時(shí)間浪費(fèi)。由于三角函數(shù)計(jì)算的重復(fù)量相當(dāng)大,故FFT能極大地提高運(yùn)算效率。頻率、周期的估計(jì)對(duì)于Y〔kf,如果當(dāng)kf=f時(shí),Y〔kf取最大值,則f為頻率的估計(jì)量,由于采樣間隔的誤差,f也存在誤差,其誤差最大值為f/2。周期T=1/f。從原理上可以看出,如果在標(biāo)準(zhǔn)信號(hào)中混有噪聲,用上述方法仍能夠精確地估計(jì)出原標(biāo)準(zhǔn)信號(hào)的頻率和周期。頻譜圖為了直觀的表示信號(hào)的頻率特性,工程上常常將傅立葉變換的結(jié)果用于圖形的方式表示,即頻譜圖。以頻譜f為橫坐標(biāo),|Y<f>|為縱坐標(biāo),可以得到幅值譜;以頻譜f為橫坐標(biāo),argY<f>為縱坐標(biāo),可以得到相位譜;以頻譜f為橫坐標(biāo),ReY<f>為縱坐標(biāo),可以得到實(shí)頻譜;以頻譜f為橫坐標(biāo),ImY<f>為縱坐標(biāo),可以得到虛頻譜;根據(jù)采樣定理,只有頻率不超過Fs/2的信號(hào)才能被正確采集,即傅立葉變換的結(jié)果中頻率大于Fs/2的部分是不正確的部分,故不在頻譜圖中顯示。即橫坐標(biāo)f屬于[0,Fs/2]。實(shí)驗(yàn)內(nèi)容請(qǐng)參考書中所給的界面和代碼,查閱相關(guān)資料,構(gòu)建交互界面,設(shè)計(jì)一個(gè)音頻頻譜分析儀,實(shí)現(xiàn)相應(yīng)的功能。實(shí)驗(yàn)程序及結(jié)果分析儀界面:輸入界面:聲卡輸入方式相關(guān)程序及結(jié)果:%---Executesonbuttonpressinsoundcard.functionsoundcard_Callback<hObject,eventdata,handles>%hObjecthandlepointtosoundcard<seeGCBO>%eventdatareserved-pointtobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata<seeGUIDATA>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'>;%Hint:get<hObject,'Value'>returnstogglestateofsoundcard%---Executesonbuttonpressinstartrecord.functionstartrecord_Callback<hObject,eventdata,handles>%hObjecthandlepointtostartrecord<seeGCBO>%eventdatareserved-pointtobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata<seeGUIDATA>Fs=str2double<get<findobj<'Tag','samplerate'>,'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.samplenum,'String',num2str<ysize<1>>>;滾動(dòng)條程序:%---Executesonslidermovement.functionscale_Callback<hObject,eventdata,handles>%hObjecthandletoscale<seeGCBO>%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata<seeGUIDATA>val=get<hObject,'value'>;val=10^<val*5+1>;x=get<handles.xmove,'Value'>*str2double<get<handles.samplenum,'String'>>;axis<handles.time,[xval+xmin<handles.y>max<handles.y>]>;%Hints:get<hObject,'Value'>returnspositionofslider%get<hObject,'Min'>andget<hObject,'Max'>todeterminerangeofslider%---Executesduringobjectcreation,aftersettingallproperties.functionscale_CreateFcn<hObject,eventdata,handles>%hObjecthandletoscale<seeGCBO>%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesempty-handlesnotcreateduntilafterallCreateFcnscalled%Hint:slidercontrolsusuallyhavealightgraybackground.ifisequal<get<hObject,'BackgroundColor'>,get<0,'defaultUicontrolBackgroundColor'>>set<hObject,'BackgroundColor',[.9.9.9]>;end%---Executesonslidermovement.functionxmove_Callback<hObject,eventdata,handles>%hObjecthandletoxmove<seeGCBO>%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata<seeGUIDATA>%get<hObject,'Min'>andget<hObject,'Max'>todeterminerangeofsliderval=get<handles.scale,'value'>;val=10^<val*5+1>;x=get<hObject,'Value'>*str2double<get<handles.samplenum,'String'>>;axis<handles.time,[xval+xmin<handles.y>max<handles.y>]>;%Hints:get<hObject,'Value'>returnspositionofslider%get<hObject,'Min'>andget<hObject,'Max'>todeterminerangeofslider%---Executesduringobjectcreation,aftersettingallproperties.functionxmove_CreateFcn<hObject,eventdata,handles>%hObjecthandletoxmove<seeGCBO>%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesempty-handlesnotcreateduntilafterallCreateFcnscalled%Hint:slidercontrolsusuallyhavealightgraybackground.ifisequal<get<hObject,'BackgroundColor'>,get<0,'defaultUicontrolBackgroundColor'>>set<hObject,'BackgroundColor',[.9.9.9]>;end%---Executesonslidermovement.functionscale2_Callback<hObject,eventdata,handles>%hObjecthandletoscale2<seeGCBO>%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata<seeGUIDATA>val=get<hObject,'value'>;val=10^<val*5+1>;xlim<handles.plot1,[0val]>;xlim<handles.plot2,[0val]>;xlim<handles.plot3,[0val]>;xlim<handles.plot4,[0val]>;%Hints:get<hObject,'Value'>returnspositionofslider%get<hObject,'Min'>andget<hObject,'Max'>todeterminerangeofslider%---Executesduringobjectcreation,aftersettingallproperties.functionscale2_CreateFcn<hObject,eventdata,handles>%hObjecthandletoscale2<seeGCBO>%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesempty-handlesnotcreateduntilafterallCreateFcnscalled%Hint:slidercontrolsusuallyhavealightgraybackground.ifisequal<get<hObject,'BackgroundColor'>,get<0,'defaultUicontrolBackgroundColor'>>set<hObject,'BackgroundColor',[.9.9.9]>;endWAV文件輸入方式相關(guān)程序及結(jié)果:%---ExecutesonbuttonpressinWAVfile.functionWAVfile_Callback<hObject,eventdata,handles>%hObjecthandlepointtoWAVfile<seeGCBO>%eventdatareserved-pointtobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata<seeGUIDATA>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'>;%Hint:get<hObject,'Value'>returnstogglestateofWAVfile%---Executesonbuttonpressinfileopen.functionfileopen_Callback<hObject,eventdata,handles>%hObjecthandlepointtofileopen<seeGCBO>%eventdatareserved-pointtobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata<seeGUIDATA>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.samplenum,'String',num2str<ysize<1>>>;信號(hào)發(fā)生器輸入方式相關(guān)程序及結(jié)果:%---Executesonbuttonpressingenerator.functiongenerator_Callback<hObject,eventdata,handles>%hObjecthandlepointtogenerator<seeGCBO>%eventdatareserved-pointtobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata<seeGUIDATA>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'>;%Hint:get<hObject,'Value'>returnstogglestateofgenerator%---Executesonbuttonpressingensig.functiongensig_Callback<hObject,eventdata,handles>%hObjecthandlepointtogensig<seeGCBO>%eventdatareserved-pointtobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata<seeGUIDATA>Fs=str2double<get<findobj<'Tag','samplerate'>,'String'>>;N=str2double<get<findobj<'Tag','samplenum'>,'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'>>;switchsoundtypecase1y=amp*sin<2*pi*x*frequency+phase>;case2y=amp*sign<sin<2*pi*x*frequency+phase>>;case3y=amp*sawtooth<2*pi*x*frequency+phase,0.5>;case4y=amp*sawtooth<2*pi*x*frequency+phase>;case5y=amp*<2*rand<size<x>>-1>;otherwiseerrordlg<'Illegalwavetype','Chooseerrer'>;endifget<handles.add,'Value'>==0.0handles.y=y;elsehandles.y=handles.y+y;endhandles.inputtype=3;guidata<hObject,handles>;plot<handles.time,handles.y>;title<'WAVE'>;axis<[0N-str2double<get<handles.amp,'String'>>str2double<get<handles.amp,'String'>>]>;正弦波:方波:三角波:鉅齒波:白噪聲:分析界面:時(shí)域分析相關(guān)程序及結(jié)果:%---Executesonbuttonpressintimeanalyse.functiontimeanalyse_Callback<hObject,eventdata,handles>%hObjecthandlepointtotimeanalyse<seeGCBO>%eventdatareserved-pointtobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata<seeGUIDATA>Fs=str2double<get<findobj<'Tag','samplerate'>,'String'>>;N=str2double<get<findobj<'Tag','samplenum'>,'String'>>;ifhandles.inputtype==0msgbox<'Nowaveexist!Pleasechooseainputtype!'>;return;end%guolingjiancen=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'>>;iffrom<1|to-from<5;msgbox<'Errorrange!'>;return;endfori=from+2:to-1;ifhandles.y<i-1><0&handles.y<i-2><0&handles.y<i>>=0&handles.y<i+1>>0ifhandles.y<i>==0ti<n>=i;elseti<n>=i-handles.y<i>/<handles.y<i>-handles.y<i-1>>;endamp<n>=<ymax-ymin>/2;ymax=0;ymin=0;n=n+1;elseifymax<handles.y<i>ymax=handles.y<i>;endifymin>handles.y<i>ymin=handles.y<i>;endendendn=n-1;%freqenceandperiodicityfori=1:n-1T<i>=ti<i+1>-ti<i>;endfreq=Fs/mean<T>;set<handles.outt,'String',1/freq>;set<handles.outfreq,'String',num2str<freq>>;%amplitudeset<handles.outamp,'String',num2str<mean<amp<2:n-1>>>>;%phasephase=2*pi*<1-<ti<1:n-1>-1>./T+floor<<ti<1:n-1>-1>./T>>;set<handles.outphase,'String',num2str<mean<phase>>>;%peakset<handles.outpeak,'String',<max<handles.y<from:to>>-min<handles.y<from:to>>>/2>;%meanset<handles.outmean,'String',mean<handles.y<from:to>>>;%meansquareset<handles.outmeansquare,'String',mean<handles.y<from:to>.^2>>;%sset<handles.outs,'String',std<handles.y<from:to>>^2>;以正弦波分析為例:頻域分析相關(guān)程序及結(jié)果:%---Executesonbuttonpressinfreqanalyse.functionfreqanalyse_Callback<hObject,eventdata,handles>%hObjecthandlepointtofreqanalyse<seeGCBO>%eventdatareserved-pointtobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata<seeGUIDATA>Fs=str2double<get<findobj<'Tag','samplerate'>,'String'>>;N=str2double<get<find

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論