1.實(shí)驗(yàn)?zāi)康?/strong>
(1)進(jìn)一步加深DFT算法原理和基本性質(zhì)的理解(因?yàn)镕FT只是DFT的一種快速算法,所以FFT的運(yùn)算結(jié)果必然滿足DFT的基本性質(zhì))。
(2)熟悉FFT算法原理和FFT程序的應(yīng)用。
(3)學(xué)習(xí)利用FFT對(duì)離散時(shí)間信號(hào)進(jìn)行頻譜分析的方法,了解可能出現(xiàn)的誤差及其原因,以便在實(shí)際中正確應(yīng)用FFT。
2.實(shí)驗(yàn)原理
用FFT對(duì)信號(hào)作頻分析是學(xué)習(xí)數(shù)字信號(hào)處理的重要內(nèi)容,經(jīng)常需要進(jìn)行分析的信號(hào)是模擬信號(hào)的時(shí)域離散信號(hào)。對(duì)信號(hào)進(jìn)行譜分析的重要問題是頻譜分辨率D和分析誤差。當(dāng)N較大時(shí),離散譜的包絡(luò)才能逼近連續(xù)譜,因此N要適當(dāng)選擇大一些。
3.運(yùn)行結(jié)果
圖1 x1(n)時(shí)域波形及幅頻特性曲線
圖2 x2(n)時(shí)域波形及幅頻特性曲線
圖3 x3(n)時(shí)域波形及幅頻特性曲線
圖4 x4(n)時(shí)域波形及幅頻特性曲線
圖5 x5(n)時(shí)域波形及幅頻特性曲線
圖6 x6(n)時(shí)域波形及幅頻特性曲線
圖7 x(n)=x4(n)+jx5(n)時(shí)域波形及幅頻特性曲線
附:程序代碼
(1)
ns=0;
nf=4;
n1=0;
n2=10;
n=[n1:n2];
x=stepseq(ns,n1,n2)-stepseq(nf,n1,n2);
subplot(3,1,1);
stem(n,x);
title('矩形序列R4(n)');
X1_8=fftshift(fft(x,8));
subplot(3,1,2);
stem(abs(X1_8));
title('N=8');
X1_16=fftshift(fft(x,16));
subplot(3,1,3);
stem(abs(X1_16));
title('N=16');
function [x,n]=stepseq(n0,n1,n2)
if n0<n1||n0>n2||n1>n2
??? error('參數(shù)須滿足n1<=n0<=n2');
end
n=[n1:n2];
x=[(n-n0)>=0];
end
(2)
n1=0;
n2=20;
n=[n1:n2];
x=zeros(1,n2-n1+1);
for i=1-n1:n2-n1+1
??? if 0<=n(i)&&n(i)<=3
??????? x(i)=n(i)+1;
??? end
??? if 4<=n(i)&&n(i)<=7
??? ????x(i)=8-n(i);
??? end
end
subplot(3,1,1);
stem(n,x);
title('函數(shù)x2(n)');
X8=fftshift(fft(x,8));
subplot(3,1,2);
stem(abs(X8));
title('N=8');
X16=fftshift(fft(x,16));
subplot(3,1,3);
stem(abs(X16));
title('N=16')
(3)
n1=0;
n2=20;
n=[n1:n2];
x=zeros(1,n2-n1+1);
for i=1-n1:n2-n1+1
??? if 0<=n(i)&&n(i)<=3
??????? x(i)=4-n(i);
??? end
??? if 4<=n(i)&&n(i)<=7
?? ?????x(i)=n(i)-3;
??? end
end
subplot(3,1,1);
stem(n,x);
title('函數(shù)x3(n)');
X8=fftshift(fft(x,8));
subplot(3,1,2);
stem(abs(X8));
title('N=8');
X16=fftshift(fft(x,16));
subplot(3,1,3);
stem(abs(X16));
title('N=16')
(4)
n1=0;
n2=31;
n=[n1:n2];
x=zeros(1,n2-n1+1);μ
for i=1-n1:n2-n1+1
??? if 0<=n(i)&&n(i)<=31
??????? x(i)=cos(pi*n(i)/8);
??? end
end
subplot(3,1,1);
stem(n,x);
title('函數(shù)x4(n)');
X16=fftshift(fft(x,16));
subplot(3,1,2);
stem(abs(X16));
title('N=16');
X32=fftshift(fft(x,32));
subplot(3,1,3);
stem(abs(X32));
title('N=32')
(5)
n1=0;
n2=31;
n=[n1:n2];
x=zeros(1,n2-n1+1);
for i=1-n1:n2-n1+1
??? if 0<=n(i)&&n(i)<=31
??????? x(i)=sin(pi*n(i)/8);
??? end
end
subplot(3,1,1);
stem(n,x);
title('函數(shù)x5(n)');
X16=fftshift(fft(x,16));
subplot(3,1,2);
stem(abs(X16));
title('N=16');
X32=fftshift(fft(x,32));
subplot(3,1,3);
stem(abs(X32));
title('N=32')
(6)
fs=64;
N1=16;
N2=32;
N3=64;
delta_t=1/fs;
t=0:delta_t:(N3-1)*delta_t;
t1=0:delta_t/10:(N3-1)*delta_t;
x6=cos(8*pi*t)+cos(16*pi*t)+cos(20*pi*t);
x6_t=cos(8*pi*t1)+cos(16*pi*t1)+cos(20*pi*t1);
x6_1=fftshift(fft(x6,N1));
x6_2=fftshift(fft(x6,N2));
x6_3=fftshift(fft(x6,N3));
subplot(5,1,1);
plot(t1,x6_t);
title('時(shí)域信號(hào)x6(t)');
subplot(5,1,2);
stem(t,x6);
title('離散序列x6(n)');
subplot(5,1,3);
stem(abs(x6_1));
title('N=16');
subplot(5,1,4);
stem(abs(x6_2));
title('N=32');
axis([0,31,0,20]);
subplot(5,1,5);
stem(abs(x6_3));
title('N=64');文章來源地址http://www.zghlxwxcb.cn/news/detail-492111.html
axis([0,63,0,40]);
(7)
n1=0;
n2=31;
n=[n1:n2];
x4=zeros(1,n2-n1+1);
for i=1-n1:n2-n1+1
??? if 0<=n(i)&&n(i)<=31
??????? x4(i)=cos(pi*n(i)/8);
??? end
end
x5=zeros(1,n2-n1+1);
for i=1-n1:n2-n1+1
??? if 0<=n(i)&&n(i)<=31
??????? x5(i)=sin(pi*n(i)/8);
??? end
end
x7=x4+j*x5;
x7_1=fftshift(fft(x7,16));
x7_2=fftshift(fft(x7,32));
x7_3=fftshift(fft(x7,64));
subplot(4,1,1);
stem(x4);
title('x7(n)的實(shí)部部分');
subplot(4,1,2);
stem(abs(x7_1));
title('N=16');
subplot(4,1,3);
stem(abs(x7_2));
title('N=32');
subplot(4,1,4);
stem(abs(x7_3));文章來源:http://www.zghlxwxcb.cn/news/detail-492111.html
title('N=64');
到了這里,關(guān)于MATLAB利用FFT對(duì)信號(hào)進(jìn)行頻譜分析的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!