天天看點

數字信号處理matlab實驗報告,數字信号處理,matlab實驗報告

數字信号處理matlab實驗報告,數字信号處理,matlab實驗報告

數字信号處理,matlab實驗報告

Matlab實驗報告 實驗一: 1. 實驗Matlab代碼: N=25; Q=0.9+0.3*j; WN=exp(-2*j*pi/N); x=zeros(25,1); at long; %長整型科學計數 for k0=1:25 x(k0,1)=Q^(k0-1); end; for k1=1:25; X1(k1,1)=(1-Q^N)/(1-Q*WN^(k1-1)); end; X1; X2=fft(x,32); subplot(3,1,1);stem(abs(X1), b. );axis([0,35,0,15]);title( N=25,ular );xlabel( n ); subplot(3,1,2);stem(abs(X2), g. );axis([0,35,0,15]);title( N=32, FFT );xlabel( n ); for(a=1:25) X3(a)=X1(a)-X2(a) end; subplot(3,1,3);stem(abs(X3), r. );title( difference );xlabel( n ); 實驗結果如圖: 實驗結論:可以看出基2時間抽選的FFT算法與利用公式法所得到的DFT結果稍有偏差,但不大,在工程上可以使用計算機利用FFT處理資料。 2. 實驗Matlab代碼: N = 1000; % Length of DFT n = [0:1:N-1]; xn = 0.001*cos(0.45*n*pi)+sin(0.3*n*pi)-cos(0.302*n*pi-pi/4); Xk = fft(xn,N); k=[0:1:N-1]; subplot(5,1,1); stem(k,abs(Xk(1:1:N))); title( DFT x(n) );xlabel( k ); axis([140,240,0,6]) subplot(5,1,2);stem(k, abs(Xk(1:1:N)), r );%畫出sin(0.3npi)-cos(0.302npi-pi/4) axis([140,160,0,6]); title( sin(0.3*pi*n)-cos(0.302*pi*n) ); xlabel( k ); subplot(5,1,3);stem(k, 1000*abs(Xk(1:1:N)), g );%畫出0.001*cos(0.45npi) axis([220,230,0,6]); title( cos(0.45*pi*n) ); xlabel( k ); subplot(5,1,4);stem(k,0.01*abs(Xk(1:1:N)), k );%畫 %sin(0.3npi)-cos(0.302npi-pi/4) axis([140,160,0,6]); title( sin(0.3*pi*n)-cos(0.302*pi*n) ); xlabel( k ); subplot(5,1,5);stem(k, 10*abs(Xk(1:1:N)), m );%畫出0.001*cos(0.45npi) axis([220,230,0,6]); title( cos(0.45*pi*n) ); xlabel( k ); 實驗結果如圖: 實驗結論: 由上圖及過程可知,當DFT變換長度為1000時所得到的譜線非常理想。由此可知當DFT變換長度N為多個數字頻率公倍數時(即數字頻率正好位于子帶的中心頻率上時),得到理想的譜線。 實驗二: 實驗Matlab代碼: num=( please your phone number: , s ); % 輸入電話号碼 len=length(num); %電話号碼長度 xx=[]; %時域信号 key=[49,50,51,65;52,53,54,66;55,56,57,67;42,48,35,68]; % DTMF表中的16個ASCII碼 frow=[697,770,852,941]; % 行頻率 fcol=[1209,1336,1477,1633]; % 列頻率 for a=1:len %循環len次 for row=1:4; for col=1:4; if num(a)==key(row,col); break; end % 檢測列号 end if num(a)==key(row,col); break, end % 檢測行号 end n=1:400; %每個号碼在時域中所占長度 fs=8000; %取樣頻率 x=sin(2*pi*n*frow(row)/fs) + sin(2*pi*n*fcol(col)/fs); %生成一個号碼的信号 x=[x,zeros(1,400)]; %加一半時間的靜音 xx=[xx x]; % 與之前信号連接配接 end sound(xx); % 發聲 wavwrite(xx, C:\Users\MATLAB\sound ) %生成檔案 subplot(2,1,1); plot(xx); title( 時域波形 ) XX=fft(xx); XXX=abs(XX); subplot(2,1,2); kk=(1:len*800)*len*fs/800; plot(kk,XXX); title( 頻譜波形 ); 實驗結果如圖: 結果分析: 時域上是11位的電話号碼在不同時間的波形,每個信号占400點,靜音400點。 頻域上可大緻看到7個峰值,是因為電話号碼中沒有列頻率最後一列的頻率值。