版權(quán)說(shuō)明:本文檔由用戶(hù)提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、<p> 基于Matlab的數(shù)字信號(hào)處理課程設(shè)計(jì)</p><p> 基于Matlab的數(shù)字信號(hào)處理課程設(shè)計(jì)</p><p><b> 一、課程設(shè)計(jì)目的:</b></p><p> 1.熟悉Matlab運(yùn)行環(huán)境,熟練使用Matlab語(yǔ)言進(jìn)行編程,進(jìn)行數(shù)字信號(hào)處理。</p><p> 2.全面復(fù)習(xí)數(shù)字信號(hào)
2、課程所學(xué)理論知識(shí),鞏固所學(xué)知識(shí)重點(diǎn)和難點(diǎn),將理論與實(shí)踐很好地結(jié)合起來(lái)。</p><p> 3.提高綜合運(yùn)用所學(xué)知識(shí)獨(dú)立分析和解決問(wèn)題的能力;</p><p> 二、 MATLAB簡(jiǎn)介</p><p> MATLAB是功能強(qiáng)大的科學(xué)及計(jì)算軟件,它不但具有以矩陣計(jì)算為基礎(chǔ)的強(qiáng)大數(shù)學(xué)計(jì)算和分析功能,而且還具有豐富的可視化圖形表現(xiàn)功能和方便的程序設(shè)計(jì)能力。MATLAB
3、的應(yīng)用領(lǐng)域極為廣泛,除了數(shù)學(xué)計(jì)算和分析外,還被廣泛地應(yīng)用于自動(dòng)控制、系統(tǒng)仿真、數(shù)字信號(hào)處理、圖形圖像分析、數(shù)理統(tǒng)計(jì)、人工智能、虛擬現(xiàn)實(shí)技術(shù)、通信工程、金融系統(tǒng)等領(lǐng)域,因此,MATLAB是面向21世紀(jì)的計(jì)算機(jī)程序設(shè)計(jì)及科學(xué)計(jì)算語(yǔ)言。</p><p> 三、MATLAB的主要組成部分</p><p> MATLAB系統(tǒng)包括5個(gè)主要部分:</p><p><b&
4、gt; (1)開(kāi)發(fā)環(huán)境</b></p><p> MATLAB開(kāi)發(fā)環(huán)境由一組工具和組件組成,這些工具是圖形化的用戶(hù)界面,包括MATLAB桌面和命令窗口、命令歷史窗口、幫助信息瀏覽器、文件和搜索路徑瀏覽器。</p><p> (2)MATLAB數(shù)學(xué)函數(shù)庫(kù)</p><p> MATLAB集成了豐富的數(shù)學(xué)函數(shù)庫(kù),其強(qiáng)大的計(jì)算能力覆蓋了從基本函數(shù)(如求和
5、、正弦、余弦和復(fù)數(shù)運(yùn)算等)到高級(jí)函數(shù)(如矩陣求逆、矩陣特征值、貝塞爾函數(shù)和快速傅立葉變換等)的范圍。</p><p> ?。?)MATLAB語(yǔ)言</p><p> MATLAB語(yǔ)言是一種以矩陣運(yùn)算為基礎(chǔ)的高級(jí)語(yǔ)言,包括控制流的描述、函數(shù)、數(shù)據(jù)結(jié)構(gòu)、輸入輸出及面向?qū)ο蟮木幊汰h(huán)境,既可以編制快速使用小程序,也可以編制大型復(fù)雜的應(yīng)用程序。</p><p><b&g
6、t; ?。?)圖形功能</b></p><p> MATLAB提供了功能強(qiáng)大的圖形系統(tǒng),既可以用高級(jí)命令完成二維和三維數(shù)據(jù)的可視化、圖像處理、動(dòng)畫(huà)和圖形表達(dá)等功能,也可以通過(guò)使用圖形句柄完成復(fù)雜的圖形功能,實(shí)現(xiàn)對(duì)所有圖形對(duì)象的操作。</p><p> ?。?)應(yīng)用程序接口(API)</p><p> MATLAB還提供了應(yīng)用程序接口庫(kù)函數(shù),允許用戶(hù)使
7、用C或FORTRAN語(yǔ)言編寫(xiě)程序與MATLAB連接,功能包括與MATLAB的動(dòng)態(tài)連接、調(diào)用MATLAB作為運(yùn)算引擎、讀寫(xiě)MAT文件等。</p><p> MATLAB的廣泛應(yīng)用促進(jìn)了其本身功能的迅速發(fā)展,以特定領(lǐng)域的應(yīng)用為主要目的的應(yīng)用程序——工具箱的數(shù)量和內(nèi)容在不斷增多。</p><p> 四、利用Matlab熟悉畫(huà)圖(設(shè)計(jì)1)</p><p> 1、設(shè)計(jì)內(nèi)
8、容:能夠利用Matlab熟悉地畫(huà)圖,內(nèi)容包括:X、Y坐標(biāo)軸上的label,每幅圖上的title,繪畫(huà)多條曲線(xiàn)時(shí)的legend,對(duì)圖形進(jìn)行適當(dāng)?shù)臉?biāo)注等。</p><p> ?。?)在一副圖上畫(huà)出多幅小圖;</p><p> (2)畫(huà)出一組二維圖形;</p><p> ?。?)畫(huà)出一組三維圖形; </p><p> ?。?)畫(huà)出復(fù)數(shù)的實(shí)
9、部與虛部。</p><p><b> 實(shí)驗(yàn)結(jié)果:</b></p><p> 、在一副圖上畫(huà)出多幅小圖;</p><p> 、畫(huà)出一組二維圖形;</p><p> 、畫(huà)出一組三維圖形;</p><p> 、畫(huà)出復(fù)數(shù)的實(shí)部與虛部;</p><p> (5)、完成對(duì)一
10、個(gè)源程序進(jìn)行詳細(xì)注釋。(見(jiàn)程序)</p><p> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%</p><p> % 能夠利用Matlab熟悉地畫(huà)圖,內(nèi)容包括:X、Y坐標(biāo)軸上的label,</p><p> % 每幅圖上的titl
11、e,繪畫(huà)多條曲線(xiàn)時(shí)的legend,對(duì)圖形進(jìn)行適當(dāng)?shù)臉?biāo)注等。</p><p> % (1)在一副圖上畫(huà)出多幅小圖;(2)畫(huà)出一組二維圖形;</p><p> % (3)畫(huà)出一組三維圖形; (4)畫(huà)出復(fù)數(shù)的實(shí)部與虛部。</p><p> % (5)完成對(duì)一個(gè)源程序進(jìn)行詳細(xì)注釋。</p><p> %%
12、%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%</p><p><b> clear;</b></p><p><b> clc;</b></p><p> x=linspace(-pi,pi,200);
13、 % 定義x軸坐標(biāo)</p><p> y1=sin(x); % 函數(shù)1</p><p> y2=cos(x); % 函數(shù)2</p><p> y3=exp(x);
14、 % 函數(shù)3</p><p> y4=sin(x).*cos(x); % 函數(shù)4</p><p> %%%%%%%%%%%%%%%%%%%%%%%%% 在一幅圖上繪制多幅小圖 %%%%%%%%%%%%%%%%%%%%%%%%%%%%</p><p><b> figure(1)</
15、b></p><p> subplot(221), % 圖一</p><p> plot(x,y1); % 繪制y1</p><p> grid on; % 添加網(wǎng)格&
16、lt;/p><p> % axis([min(x) max(x) min(y1) max(y1)]); % 指定顯示范圍</p><p> subplot(222), % 圖二</p><p> hist(y2); % 繪制y2</
17、p><p> grid on; % 添加網(wǎng)格</p><p> % axis([min(x) max(x) min(y2) max(y2)]); % 指定顯示范圍</p><p> subplot(223), % 圖三</p>
18、;<p> stem(x,y3); % 繪制y3</p><p> grid on; % 添加網(wǎng)格</p><p> % axis([min(x) max(x) min(y3) max(y3)]); % 指定顯示范圍</p>
19、<p> subplot(224), % 圖四</p><p> plot(x,y4,'rp'); % 繪制y4</p><p> grid on; % 添加網(wǎng)格</p>
20、;<p> % axis([min(x) max(x) min(y4) max(y4)]); % 指定顯示范圍</p><p> %%%%%%%%%%%%%%%%%%%%%%%%%%%%% 畫(huà)出一組二維圖形 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%</p><p> figure(2)
21、 </p><p> a=linspace(0,2*pi,200);</p><p> k=[1,2,3];</p><p> y=sin(a')*k;</p><p> plot(a,y(:,1),a,y(:,2),a,y(:,3));</p><p> legend(['y= '
22、,num2str(k(1)),'*sin(x)'],['y= ',num2str(k(2)),'*sin(x)']...</p><p> ,['y= ',num2str(k(3)),'*sin(x)']);</p><p> xlabel('x');</p><p>
23、; ylabel('y');</p><p> title('多條曲線(xiàn)繪制');</p><p><b> grid on;</b></p><p> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 畫(huà)出一組三維圖形 %%%%%%%%%%%%%%%%%%%%%%%%%%%%</p>
24、;<p> figure(3) </p><p><b> kk=30;</b></p><p> x=linspace(-5,5,kk);</p><p> y=linspace(-5,5,kk);</p><p> for i=
25、1:kk</p><p> for j=1:kk</p><p> z(i,j)=sin(x(i))+cos(y(j));</p><p><b> end</b></p><p><b> end</b></p><p> surf(x,y,z);</p&g
26、t;<p> xlabel('x');</p><p> ylabel('y');</p><p> zlabel('z');</p><p> title('z=sin^2(x)/(3*y-2)');</p><p> %%%%%%%%%%%%%%%%%
27、%%%%%%%%%%%%%%%%% 復(fù)數(shù)繪制 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%</p><p> figure(4) </p><p><b> clear</b></p><p> kk=1:1:10;</p><p> for i=1:10</p><p&g
28、t; y(i)=sin(kk(i))+cos(kk(i))/kk(i)*j;</p><p><b> end</b></p><p> compass(y);</p><p> 五、褶積的相關(guān)計(jì)算與編程(設(shè)計(jì)2)</p><p> 設(shè)計(jì)內(nèi)容:計(jì)算普通褶積與循環(huán)褶積,分別使用時(shí)間域與頻率域兩種方法進(jìn)行正、反演計(jì)
29、算,指出循環(huán)褶積計(jì)算時(shí)所存在的邊界效應(yīng)現(xiàn)象;編寫(xiě)一個(gè)做相關(guān)分析的源程序。</p><p><b> 實(shí)驗(yàn)成果:</b></p><p> ?。?)、構(gòu)造如下兩個(gè)向量:a=[1,2,3,4]; b=[9,8,7,6]; </p><p><b> 計(jì)算得到:</b></p><p> 從計(jì)
30、算結(jié)果可以看出,當(dāng)循環(huán)次數(shù)小于N1+N2-1時(shí),線(xiàn)性褶積和循環(huán)褶積不等,</p><p> 當(dāng)循環(huán)次數(shù)大于等于N1+N2-1時(shí),線(xiàn)性褶積和循環(huán)褶積相等。</p><p> (2)、構(gòu)造兩個(gè)向量:a=[1 2 3]; b=[1 2 3 5];</p><p> 計(jì)算相關(guān)得到:頻率域: [14 13 16 23]</p><p> 時(shí)
31、間域(6次): [14 8 3 5 13 23]</p><p><b> 程序:</b></p><p><b> 褶 積 </b></p><p> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%</p&
32、gt;<p> % 計(jì)算普通褶積與循環(huán)褶積,分別使用時(shí)間域與頻率域兩種方法</p><p> % 進(jìn)行正、反演計(jì)算,指出循環(huán)褶積計(jì)算時(shí)所存在的邊界效應(yīng)現(xiàn)象;</p><p> % 編寫(xiě)一個(gè)做相關(guān)分析的源程序。 </p><p> %%%%%%
33、%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%</p><p> % 驗(yàn)證循環(huán)褶積和線(xiàn)性褶積在什么條件下相等</p><p> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
34、%%%%%%%%</p><p><b> clc;</b></p><p><b> clear;</b></p><p> a=[1,2,3,4]; % a矩陣</p><p> b=[9,8,7,6]; % b矩陣</p>
35、<p> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%</p><p> kk1=length(a);</p><p> kk2=length(b);</p><p> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
36、%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%</p><p> % 循環(huán)褶積 時(shí)間域</p><p> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%</p><p> xx=
37、8; % 循環(huán)次數(shù) 手動(dòng)更改</p><p> aa=zeros(xx,1);</p><p> aa(1:kk1,1)=a'; % 擴(kuò)展a</p><p> bb=zeros(xx,1);</p><p> bb(1:kk2,1)=b'; %
38、擴(kuò)展b</p><p> bb1=zeros(xx,xx); % 循環(huán)矩陣</p><p> for i=1:xx</p><p> bb1(i:xx,i)=bb(1:xx-i+1);</p><p> bb1(1:i-1,i)=bb(xx-i+2:xx);</p><p><b>
39、end</b></p><p> ok1=bb1*aa; % 循環(huán)褶積結(jié)果</p><p> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%</p><p> % 線(xiàn)性褶
40、積 時(shí)間域</p><p> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%</p><p> bb2=zeros(kk1+kk2-1,kk1);</p><p> for i=1:kk1</p><p> bb2(i:i+kk2-
41、1,i)=b(1:kk2)';</p><p><b> end</b></p><p><b> an=a';</b></p><p> ok2=bb2*an; % 線(xiàn)性褶積結(jié)果</p><p> %%%%%%%%%%%%%%%%%%%%%%%%%
42、%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%</p><p> % 循環(huán)褶積 頻率域</p><p> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%</p>&l
43、t;p> af=fft(aa);</p><p> bf=fft(bb);</p><p> ok3=ifft(af.*bf);</p><p><b> 相 關(guān) </b></p><p> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
44、%%%%%%%%%%%%%%%%%%</p><p> % 計(jì)算普通褶積與循環(huán)褶積,分別使用時(shí)間域與頻率域兩種方法進(jìn)行</p><p> % 正、反演計(jì)算,指出循環(huán)褶積計(jì)算時(shí)所存在的邊界效應(yīng)現(xiàn)象;</p><p> % 編寫(xiě)一個(gè)做相關(guān)分析的源程序。 <
45、;/p><p> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%</p><p> % 求兩個(gè)一維數(shù)組的相關(guān)系數(shù)</p><p> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
46、%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%</p><p><b> clear;</b></p><p><b> clc;</b></p><p> a=[1 2 3]; % 數(shù)組a 較短時(shí)可以手動(dòng)輸入</p><p> b=[
47、1 2 3 5]; % 數(shù)組b 較短時(shí)可以手動(dòng)輸入</p><p> % a=csvread('**.csv',0,0); % 數(shù)組a 較長(zhǎng)時(shí)可以讀取csv文件</p><p> % b=csvread('**.csv',0,0); % 數(shù)組a 較長(zhǎng)時(shí)可以讀取csv文件</p>&
48、lt;p> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%</p><p> % 頻率域求相關(guān)</p><p> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
49、%%%%%%%%%%%%%%%%%%%%%%%</p><p> a2=zeros(1,max(length(a),length(b)));</p><p> b2=zeros(1,max(length(a),length(b)));</p><p> a2(1,1:length(a))=a;</p><p> b2(1,1:leng
50、th(b))=b;</p><p> ffta=fft(a2);</p><p> fftb=fft(b2);</p><p> fftb=conj(fftb);</p><p> result=(ifft(ffta.*fftb))' % 頻率域求相關(guān)結(jié)果</p><p> %%%%%%%
51、%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%</p><p> % 時(shí)間域求相關(guān)</p><p> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
52、%%%%%%</p><p> long=length(a)+length(b)-1;</p><p> aa=zeros(long,1);</p><p> bb=zeros(long,1);</p><p> aa(1:length(a),1)=a';</p><p> bb(1:length(b
53、),1)=b';</p><p> temp=zeros(long);</p><p> for i=1:long</p><p> temp(1:long-i+1,i)=aa(i:long);</p><p> temp(long-i+2:long,i)=aa(1:i-1);</p><p><
54、b> end</b></p><p> result2=temp*(bb) % 時(shí)間域求循環(huán)相關(guān)</p><p> 六、設(shè)計(jì)一維濾波處理程序(設(shè)計(jì)3)</p><p> 實(shí)驗(yàn)內(nèi)容:設(shè)計(jì)一個(gè)一維濾波處理程序(1、分別做低通、高通、帶通、帶阻等理想濾波器進(jìn)行處理;2、窗函數(shù))</p><p>
55、;<b> 實(shí)驗(yàn)結(jié)果:</b></p><p> 、一維信號(hào)理想濾波器</p><p><b> ?。?)、窗函數(shù)</b></p><p><b> 程序:</b></p><p> 一 維 理 想 濾 波 器 </p><p> %%%%%
56、%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%</p><p> % 一維信號(hào)濾波器設(shè)計(jì)</p><p> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
57、%%%%%</p><p> function varargout = num4_1lvbo(varargin)</p><p> % Begin initialization code - DO NOT EDIT</p><p> gui_Singleton = 1;</p><p> gui_State = struct('
58、;gui_Name', mfilename, ...</p><p> 'gui_Singleton', gui_Singleton, ...</p><p> 'gui_OpeningFcn', @num4_1lvbo_OpeningFcn, ...</p><p> 'gui_OutputFcn
59、', @num4_1lvbo_OutputFcn, ...</p><p> 'gui_LayoutFcn', [] , ...</p><p> 'gui_Callback', []);</p><p> if nargin && ischar(varargin{1})</p>&
60、lt;p> gui_State.gui_Callback = str2func(varargin{1});</p><p><b> end</b></p><p> if nargout</p><p> [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});&
61、lt;/p><p><b> else</b></p><p> gui_mainfcn(gui_State, varargin{:});</p><p><b> end</b></p><p> function num4_1lvbo_OpeningFcn(hObject, eventdat
62、a, handles, varargin)</p><p> handles.output = hObject;</p><p> guidata(hObject, handles);</p><p> function varargout = num4_1lvbo_OutputFcn(hObject, eventdata, handles) </p&g
63、t;<p> varargout{1} = handles.output;</p><p> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%</p><p> % 全局變量說(shuō)明</p><p&g
64、t; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%</p><p> % yuchu 用于存放信號(hào)FFT變換結(jié)果</p><p> % long 用于存放信號(hào)長(zhǎng)度</p><p> % ys
65、 用于存放原始信號(hào)</p><p> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%</p><p> % 讀取原始信號(hào)并進(jìn)行預(yù)處理</p><p> %%%%%%%%%%%%%%%%%%%%
66、%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%</p><p> function bt_read_Callback(hObject, eventdata, handles)</p><p> [FileName,PathName] = uigetfile('*.csv') </p>&
67、lt;p><b> global ys</b></p><p> ys=csvread(FileName);</p><p> axes(handles.wave_ys);</p><p> plot(ys(:,1),ys(:,2)); </p><p><b> gri
68、d on;</b></p><p> axis([min(ys(:,1)) max(ys(:,1)) min(ys(:,2))*3/2 max(ys(:,2))*3/2]);</p><p> global yuchu </p><p> yuchu=fft(ys(:,2));</p>&l
69、t;p> global long </p><p> long=length(ys(:,2));</p><p> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%</p><p> %
70、 低通濾波</p><p> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%</p><p> function bt_dt_Callback(hObject, eventdata, handles)</p><p>
71、global yuchu long ys</p><p> f1=str2double(get(handles.input_f1,'string'));</p><p> for i=1:long</p><p> if i<=(fix(long/2)+1)*f1 || i>=(fix(long/2)+1)-(fix(long/2)
72、+1)*f1+...</p><p> (fix(long/2)+1)</p><p> dt(i)=yuchu(i);</p><p><b> else</b></p><p><b> dt(i)=0;</b></p><p><b> end<
73、;/b></p><p><b> end</b></p><p> ok=ifft(dt);</p><p> axes(handles.wave_dt);</p><p> plot(ys(:,1),ok);</p><p><b> grid on;</b&g
74、t;</p><p> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%</p><p> % 高通濾波</p><p> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
75、%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%</p><p> function bt_gt_Callback(hObject, eventdata, handles)</p><p> global yuchu long ys</p><p> f1=str2double(get(handles.input_f1,'str
76、ing'));</p><p> for i=1:long</p><p> if i<=(fix(long/2)+1)*f1 || i>=(fix(long/2)+1)-(fix(long/2)+1)*f1+...</p><p> (fix(long/2)+1)</p><p><b> gt(i)=
77、0;</b></p><p><b> else</b></p><p> gt(i)=yuchu(i);</p><p><b> end</b></p><p><b> end</b></p><p> ok=ifft(gt)
78、;</p><p> axes(handles.wave_gt);</p><p> plot(ys(:,1),ok);</p><p><b> grid on;</b></p><p> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
79、%%%%%%%%%%%%%%</p><p> % 帶阻濾波</p><p> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%</p><p> function bt_dz_Callback(hOb
80、ject, eventdata, handles)</p><p> global yuchu long ys</p><p> f1=str2double(get(handles.input_f1,'string'));</p><p> f2=str2double(get(handles.input_f2,'string')
81、);</p><p> for i=1:long</p><p> if (i>=(fix(long/2)+1)*f1 && i<=(fix(long/2)+1)*f2) || ...</p><p> (i<=(fix(long/2)+1)-(fix(long/2)+1)*f1+(fix(long/2)+1)...</
82、p><p> && i>=(fix(long/2)+1)-(fix(long/2)+1)*f2+(fix(long/2)+1))</p><p><b> dz(i)=0;</b></p><p><b> else</b></p><p> dz(i)=yuchu(i);
83、</p><p><b> end</b></p><p><b> end</b></p><p> ok=ifft(dz);</p><p> axes(handles.wave_dz);</p><p> plot(ys(:,1),ok);</p>
84、<p><b> grid on;</b></p><p> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%</p><p> % 帶通濾波</p><p> %
85、%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%</p><p> function bt_dat_Callback(hObject, eventdata, handles)</p><p> global yuchu long ys</p><p> f1=s
86、tr2double(get(handles.input_f1,'string'));</p><p> f2=str2double(get(handles.input_f2,'string'));</p><p> for i=1:long</p><p> if (i>=(fix(long/2)+1)*f1 &&
87、amp; i<=(fix(long/2)+1)*f2) || ...</p><p> (i<=(fix(long/2)+1)-(fix(long/2)+1)*f1+(fix(long/2)+1)...</p><p> && i>=(fix(long/2)+1)-(fix(long/2)+1)*f2+(fix(long/2)+1))</p>
88、;<p> dz(i)=yuchu(i);</p><p><b> else</b></p><p><b> dz(i)=0;</b></p><p><b> end</b></p><p><b> end</b></
89、p><p> ok=ifft(dz);</p><p> axes(handles.wave_dat);</p><p> plot(ys(:,1),ok);</p><p><b> grid on;</b></p><p><b> 窗 函 數(shù) </b></
90、p><p> function varargout = num4_windows(varargin)</p><p> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%</p><p> % 本程序用于對(duì)一維信號(hào)進(jìn)行窗函數(shù)濾波</p><p&g
91、t; % 其中,f1、f2、f3、f4依次為</p><p> % 帶通濾波鑲邊后的四個(gè)頻率</p><p> % 為了使濾波效果較好,建議使 f1-f2=f3-f4</p><p> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%</p>
92、<p> gui_Singleton = 1;</p><p> gui_State = struct('gui_Name', mfilename, ...</p><p> 'gui_Singleton', gui_Singleton, ...</p><p> 'gui_OpeningFcn
93、', @num4_windows_OpeningFcn, ...</p><p> 'gui_OutputFcn', @num4_windows_OutputFcn, ...</p><p> 'gui_LayoutFcn', [] , ...</p><p> 'gui_Callback', [
94、]);</p><p> if nargin && ischar(varargin{1})</p><p> gui_State.gui_Callback = str2func(varargin{1});</p><p><b> end</b></p><p> if nargout</p
95、><p> [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});</p><p><b> else</b></p><p> gui_mainfcn(gui_State, varargin{:});</p><p><b> end&l
96、t;/b></p><p> function num4_windows_OpeningFcn(hObject, eventdata, handles, varargin)</p><p> handles.output = hObject;</p><p> guidata(hObject, handles);</p><p>
97、 function varargout = num4_windows_OutputFcn(hObject, eventdata, handles) </p><p> varargout{1} = handles.output;</p><p> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
98、%%%%%%</p><p> % 以下為信號(hào)讀取以及原始信號(hào)的繪制</p><p> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%</p><p> function read_Callback(hObject, e
99、ventdata, handles)</p><p> [FileName,PathName] = uigetfile('*.csv') % read file </p><p> global sign</p><p> sign=csvread(FileName);</p><p> axes(handles
100、.axes_sign)</p><p> plot(1:length(sign'),sign(:,2))</p><p><b> grid on</b></p><p> function plot_Callback(hObject, eventdata, handles)</p><p> % 采樣頻
101、率100Hz,Wpl=20Hz,Wph=30Hz,Wsl=15Hz,Wsh=35Hz,</p><p> % 頻率/采樣頻率*2*pi</p><p> % Wpl=0.4*pi,Wph=0.6*pi,Wsl=0.2*pi,Wsh=0.8*pi,</p><p> % Rp=1;As=20</p><p><b> clc;
102、</b></p><p> T = 1; Fs = 1/T; % Set T=1</p><p> %%%%%%%%%%%%%%%%%%%%%按照比值進(jìn)行帶通的四個(gè)頻率成份的界定 %%%%%%%%%%%%%%%%%%%%</p><p> f1=str2double(get(handles.input_f1,'string'));&
103、lt;/p><p> f2=str2double(get(handles.input_f2,'string'));</p><p> f3=str2double(get(handles.input_f3,'string'));</p><p> f4=str2double(get(handles.input_f4,'stri
104、ng'));</p><p> %--------------------------------------------------------------------------</p><p> global sign</p><p> kk=length(sign'); % 一維信號(hào)長(zhǎng)度</p><p>
105、 Wpl=tan(f2/2/Fs*pi);</p><p> Wph=tan(f3/2/Fs*pi);</p><p> Wsl=tan(f1/2/Fs*pi);</p><p> Wsh=tan(f4/2/Fs*pi);</p><p><b> Rp = 1;</b></p><p>
106、;<b> As= 40;</b></p><p> % 計(jì)算模擬低通原型的參數(shù)</p><p> OmigaP=Wph-Wpl; % 低通濾波器通帶截止頻率</p><p> OmigaS=Wsh-Wsl; % 低通濾波器通帶截止頻率</p><p> [N,Wn]=buttord(OmigaP,OmigaS
107、,Rp,As,'s');</p><p> [B,A]=butter(N,Wn,'s');</p><p> [BT,AT]=lp2bp(B,A,sqrt(Wph*Wpl),Wph-Wpl);</p><p> [b,a]=bilinear(BT,AT,Fs);</p><p> H=freqz(b,a
108、,kk,'whole');</p><p> axes(handles.axes_ifft) % 輸出濾波器</p><p> plot(1:kk,ifft(abs(H).*fft(sign(:,2))),'r');</p><p><b> grid on;</b></p><p&g
109、t; axes(handles.axes_fft) % 輸出濾波后的信號(hào)</p><p> plot(abs(H),'r');</p><p><b> grid on;</b></p><p> 六、驗(yàn)證褶積性質(zhì)(設(shè)計(jì)4)</p><p> 設(shè)計(jì)內(nèi)容:驗(yàn)證時(shí)間域的循環(huán)褶積對(duì)應(yīng)的是頻率域的乘
110、積;線(xiàn)性褶積則不然。</p><p><b> 實(shí)驗(yàn)結(jié)果:</b></p><p> a,b兩向量取如下值:a=[1,2,3,4]; b=[1,2,3];</p><p><b> 計(jì)算得到如下結(jié)果:</b></p><p> 當(dāng)循環(huán)次數(shù)依次為4,5,6,7時(shí),在頻率域和時(shí)間域計(jì)算得到的循
111、環(huán)褶積均相等;</p><p> 當(dāng)循環(huán)次數(shù)小于6(N1+N2-1)時(shí),時(shí)間域和頻率域計(jì)算所得的結(jié)果不同,但是當(dāng)循環(huán)次數(shù)大于6時(shí),兩種方法計(jì)算得到的結(jié)果相等。</p><p> 因此可以得到如下結(jié)論:</p><p> 兩個(gè)向量的循環(huán)褶積所對(duì)應(yīng)的頻譜是兩信號(hào)各自頻譜在頻率域的乘積;</p><p> 當(dāng)兩個(gè)向量在頻率域計(jì)算線(xiàn)性褶積時(shí),
112、要對(duì)兩個(gè)信號(hào)進(jìn)行補(bǔ)零擴(kuò)展,使兩個(gè)信號(hào)同大小。當(dāng)擴(kuò)展出的新信號(hào)長(zhǎng)度小于臨界長(zhǎng)度6(N1+N2-1)時(shí),頻率域和時(shí)間域計(jì)算得到的線(xiàn)性褶積不相等;當(dāng)擴(kuò)展出的新信號(hào)長(zhǎng)度大于等于臨界長(zhǎng)度6(N1+N2-1)時(shí),頻率域和時(shí)間域計(jì)算得到的線(xiàn)性褶積相等。</p><p> 例如:設(shè)length(a)=n1 length(b)=n2 length(新信號(hào))=n3</p><p> 如果 n3&
113、lt;n1+n2-1 兩種方法所得結(jié)果不等;</p><p> 如果 n3>=n1+n2-1 兩種方法所得結(jié)果相等;</p><p><b> 程序: </b></p><p> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
114、%%%%%%%%%%%</p><p> % 驗(yàn)證時(shí)間域的循環(huán)褶積對(duì)應(yīng)的是頻率域的乘積;線(xiàn)性褶積則不然。</p><p> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%</p><p><b> clear;</b><
115、;/p><p><b> clc;</b></p><p> a=[1,2,3,4];</p><p> b=[1,2,3];</p><p> kk1=length(a);</p><p> kk2=length(b);</p><p> '臨界循環(huán)次數(shù)(
116、循環(huán)=線(xiàn)性)'</p><p> minl=length(a)+length(b)-1 % 臨界循環(huán)次數(shù)(循環(huán)=線(xiàn)性)</p><p><b> '循環(huán)次數(shù)'</b></p><p> xx=4 % 循環(huán)次數(shù) 手動(dòng)更改 >=max(length(a),l
117、ength(b))</p><p> aa=zeros(xx,1);</p><p> aa(1:kk1,1)=a'; % 擴(kuò)展a</p><p> bb=zeros(xx,1);</p><p> bb(1:kk2,1)=b'; % 擴(kuò)展b</p>
118、<p> bb1=zeros(xx,xx); % 循環(huán)矩陣</p><p> for i=1:xx</p><p> bb1(i:xx,i)=bb(1:xx-i+1);</p><p> bb1(1:i-1,i)=bb(xx-i+2:xx);</p><p><b> end</b
119、></p><p> '時(shí)間域計(jì)算循環(huán)褶積結(jié)果'</p><p> ok1=bb1*aa % 時(shí)間域計(jì)算循環(huán)褶積結(jié)果</p><p> '頻率域計(jì)算循環(huán)褶積結(jié)果'</p><p> ok2=ifft(fft(aa).*fft(bb)) % 頻率域計(jì)算循環(huán)褶積
120、結(jié)果</p><p><b> '作差比較'</b></p><p> plus1=ok1-ok2 % 作差比較</p><p> '時(shí)間域計(jì)算線(xiàn)性褶積結(jié)果'</p><p> ok3=conv(a,b) % 時(shí)間域計(jì)
121、算線(xiàn)性褶積結(jié)果</p><p><b> kk=5</b></p><p> aa=zeros(kk,1);</p><p> aa(1:kk1,1)=a'; % 擴(kuò)展a</p><p> bb=zeros(kk,1);</p><p> bb(1:k
122、k2,1)=b'; </p><p> '頻率域計(jì)算線(xiàn)性褶積結(jié)果'</p><p> ok4=ifft(fft(aa).*fft(bb)) % 頻率域計(jì)算線(xiàn)性褶積結(jié)果</p><p> ok33=zeros(length(ok3)+length(ok4),1);</p><p> ok33(1:lengt
123、h(ok3),1)=ok3;</p><p> ok44=zeros(length(ok3)+length(ok4),1);</p><p> ok44(1:length(ok4),1)=ok4;</p><p><b> '作差比較'</b></p><p> plus2=ok33-ok44
124、 % 作差比較</p><p><b> 七、實(shí)習(xí)感想</b></p><p> 通過(guò)這次的計(jì)算機(jī)編程與數(shù)字信號(hào)處理實(shí)習(xí),使我對(duì)數(shù)字信號(hào)處理的了解有了很大的提高。老師生動(dòng)細(xì)致的講解和悉心輔導(dǎo)讓人印象深刻。在此,首先要對(duì)老師的指導(dǎo)致以深深的謝意。</p><p> 剛剛開(kāi)始的時(shí)候,我感覺(jué)對(duì)MATLAB比較生疏,編程時(shí)
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶(hù)所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 眾賞文庫(kù)僅提供信息存儲(chǔ)空間,僅對(duì)用戶(hù)上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶(hù)上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶(hù)因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 數(shù)字信號(hào)處理課程設(shè)計(jì)--基于matlab的數(shù)字圖像處理
- 基于matlab的數(shù)字信號(hào)處理與分析課程設(shè)計(jì)
- 數(shù)字信號(hào)處理課程設(shè)計(jì)--使用matlab工具進(jìn)行數(shù)字信號(hào)處理
- 數(shù)字信號(hào)處理課程設(shè)計(jì)-使用matlab工具進(jìn)行數(shù)字信號(hào)處理
- 數(shù)字信號(hào)處理課程設(shè)計(jì)--基于 matlab 的音樂(lè)信號(hào)處理和分析
- 數(shù)字信號(hào)處理課程設(shè)計(jì)---基于matlab的語(yǔ)音信號(hào)濾波處理
- 基于matlab的語(yǔ)音信號(hào)濾波處理——數(shù)字信號(hào)處理課程設(shè)計(jì)
- 《數(shù)字信號(hào)處理》課程設(shè)計(jì)--基于matlab的音樂(lè)信號(hào)處理和分析
- 基于matlab的語(yǔ)音信號(hào)濾波處理——數(shù)字信號(hào)處理課程設(shè)計(jì)
- 數(shù)字信號(hào)處理課程設(shè)計(jì)--基于matlab有噪聲語(yǔ)音信號(hào)處理
- 數(shù)字信號(hào)課程設(shè)計(jì)--數(shù)字信號(hào)處理
- 數(shù)字信號(hào)課程設(shè)計(jì)--語(yǔ)音數(shù)字信號(hào)處理與分析及matlab實(shí)現(xiàn)
- 數(shù)字信號(hào)處理課程設(shè)計(jì)--基于 matlab 的語(yǔ)音去噪處理
- 數(shù)字信號(hào)處理課程設(shè)計(jì)報(bào)告--基于matlab的語(yǔ)音去噪處理
- 數(shù)字信號(hào)處理matlab濾波器課程設(shè)計(jì)
- 數(shù)字信號(hào)處理課程設(shè)計(jì)---基于matlab的濾波器的設(shè)計(jì)
- 數(shù)字信號(hào)處理課程設(shè)計(jì)
- 數(shù)字信號(hào)處理課程設(shè)計(jì)
- 數(shù)字信號(hào)處理課程設(shè)計(jì)
- 數(shù)字信號(hào)處理課程設(shè)計(jì)
評(píng)論
0/150
提交評(píng)論