資源描述:
《數(shù)字信號處理,matlab實驗報告》由會員上傳分享,免費在線閱讀,更多相關(guān)內(nèi)容在教育資源-天天文庫。
1、Matlab實驗報告實驗一:1.實驗Matlab代碼:N=25;Q=0.9+0.3*j;WN=exp(-2*j*pi/N);x=zeros(25,1);formatlong;%長整型科學計數(shù)fork0=1:25x(k0,1)=Q^(k0-1);end;fork1=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,formular');xlabel('n');subplot(3,1,2)
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');實驗結(jié)果如圖:實驗結(jié)論:可以看出基2時間抽選的FFT算法與利用公式法所得到的DFT結(jié)果稍有偏差,但不大,在工程上可以使用計算機利用FFT處理數(shù)據(jù)。2.實驗Matlab代碼:N=1000;%LengthofDFTn=[0:1:N-1];xn=0.001
3、*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('DFTx(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*
4、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')
5、;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');實驗結(jié)果如圖:實驗結(jié)論:由上圖及過程可知,當DFT變換長度為1000時所得到的譜線非常理想。由此可知當DFT變換長度N為多個數(shù)字頻率公倍數(shù)時(即數(shù)字頻率正好位于子帶的中心頻率上時),得到理想的譜線。實驗二:實驗Matlab代碼:num=input('pleaseinputyourphonenumber:','s');%輸入電話號碼le
6、n=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];%列頻率fora=1:len%循環(huán)len次forrow=1:4;forcol=1:4;ifnum(a)==key(row,col);break;end%檢測列號endifnum(a)==key(row,col);break,end%檢測行號endn=1:400;%每個
7、號碼在時域中所占長度fs=8000;%取樣頻率x=sin(2*pi*n*frow(row)/fs)+sin(2*pi*n*fcol(col)/fs);%生成一個號碼的信號x=[x,zeros(1,400)];%加一半時間的靜音xx=[xxx];%與之前信號連接endsound(xx);%發(fā)聲wavwrite(xx,'C:UsersMATLABsound')%生成文件subplot(2,1,1);plot(xx);title('時域波形')XX=fft(xx);XXX=abs(XX);subplot