一、谱分析概念
信号的谱分析就是计算信号的频谱(信号的傅里叶变换),通过信号研究分析信号特性。信号频谱是连续的,不能用数字信号处理方法计算,按频域采样定理,序列的DFT
完整反映了频谱信息,所以可以通过DFT
进行谱分析。
二 DFT对离散序列进行谱分析
2.1 非周期序列进行谱分析
傅里叶变换定义:
DFT
定义:
有限长序列$x(n)$的N点离散傅里叶变换$X(k)$是$x(n)$的傅里叶变换$X(e^{jw})$在一个周期上的N点等间隔采样值,DFT满足频域采样定理。由频域采样定理可知,$X(k)$包含了频谱$X(e^{jw})$的全部信息,因此,求$x(n)$的DFT就可以分析它的频谱了。即通过DFT进行谱分析。
2.2 周期序列进行谱分析
以周期为N的周期序列$x(n)$进行$DFS$,以所求出的$DFS$系数作为各谐波分量的幅度形成其频谱函数:
其中$X(k)=DFT[x(n)]=\sum_{n=0}^{N-1}x(n)e^{-j\frac{2\pi}{N}kn}$。截取$x(n)$的整数个周期做$DFT$,也可以获得$x(n)$频谱结构。截取M等于$x(n)$的整数个周期,即$M=mN$,m为正整数,则:
2.3 连续信号进行谱分析
对连续信号$X_a(t)$,为了利用DFT分析其频谱,需要将其离散化,若信号持续时间无限长,还需要对它进行截短近似。所以从严格意义上讲用DFT对信号进行谱分析,都是某种意义上的近似。
三、FFT进行频谱分析
3.1 练习一
绘制下面信号的8点FFT:
1 2 3 4 5 6 7 8 9 10 11 12
| N = 8; x = [4:-1:1 1:4]; xk = fft(x,N);
figure; subplot(1, 2, 1); stem(0:length(x)-1, x, "."); title("x3的波形");
subplot(1, 2, 2); stem(0:N-1, xk, "."); title("x3的8点FFT");
|

3.2 练习二
绘制下面信号的8点和16点FFT:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| N1 = 8; N2 = 16;
x1 = [1 1 1 1 0 0 0 0]; xk8 = fft(x1, N1); xk16 = fft(x1, N2); xk8 = abs(xk8); xk16 = abs(xk16);
figure; subplot(2, 1, 1); stem(0:length(x1)-1, x1, "filled"); title("x1的波形"); subplot(2, 1, 2); stem(0:N1-1, xk8, "fill"); title("x1的8点FFT");
figure; subplot(2, 1, 1); stem(0:length(x1)-1, x1, "filled"); title("x1的波形"); subplot(2, 1, 2); stem(0:N2-1, xk16, "filled"); title("x1的16点FFT");
|


3.3 练习三
绘制下面信号的8点和16点FFT:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| x = [1:4 4:-1:1]; N1 = 8; N2 = 16; X1 = abs(fft(x, 8)); X2 = abs(fft(x, 16));
figure; subplot(2, 1, 1); stem(0:length(x)-1, x, "filled"); title("x2的波形"); subplot(2, 1, 2); stem(0:N1-1, X1,"filled"); title("x2的8点FFT");
figure; subplot(2, 1, 1); stem(0:length(x)-1, x, "filled"); title("x2的波形"); subplot(2, 1, 2); stem(0:N2-1, X2,"filled"); title("x2的16点FFT");
|


3.4 练习四
绘制下面信号的8点和16点FFT:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| x = [0:pi:7*pi]; x1 = [0:pi:15*pi]; y = cos(x/4); y0 = cos(x1/4); N1 = 8; N2 = 16; y1 = fft(y, N1); y2 = fft(y0, N2);
figure; subplot(2, 1, 1); stem(x/pi, y, "."); title("x4的波形"); subplot(2, 1, 2); stem(0:N1-1, y1, "."); title("x4的8点FFT");
figure; subplot(2, 1, 1); stem(x1/pi, y0, "."); title("x4的波形"); subplot(2, 1, 2); stem(0:N2-1, y2, "."); title("x4的16点FFT");
|


3.5 练习五
对下面信号以fs=64(Hz)采样后做N=16、32、64点的FFT:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
| clc; clear;
fs = 64; t = 1/fs;
N61 = 16; n61 = 0:N61-1; x61 = cos(8*pi*n61*t)+cos(16*pi*n61*t)+cos(20*pi*n61*t); X61 = fft(x61,N61); subplot(3,1,1); stem(0:length(x61)-1,x61,'.'); title('x6(n)的波形'); grid on; subplot(3,1,2); stem(0:N61-1,abs(X61),'.'); title('x6(n)的16点FFT幅频'); grid on; subplot(3,1,3); stem(0:N61-1,angle(X61),'.'); title('x6(n)的16点FFT相频'); grid on; figure;
N62 = 32; n62 = 0:N62-1; x62 = cos(8*pi*n62*t)+cos(16*pi*n62*t)+cos(20*pi*n62*t); X62 = fft(x62,N62); subplot(3,1,1); stem(0:length(x62)-1,x62,'.'); title('x6(n)的波形'); grid on; subplot(3,1,2); stem(0:N62-1,abs(X62),'.'); title('x6(n)的32点FFT幅频'); grid on; subplot(3,1,3); stem(0:N62-1,angle(X62),'.'); title('x6(n)的32点FFT相频'); grid on; figure;
N6 = 64; n6 = 0:N6-1; x6 = cos(8*pi*n6*t)+cos(16*pi*n6*t)+cos(20*pi*n6*t); X6 = fft(x6,N6); subplot(3,1,1); stem(0:length(x6)-1,x6,'.'); title('x6(n)的波形'); grid on; subplot(3,1,2); stem(0:N6-1,abs(X6),'.'); title('x6(n)的64点FFT幅频'); grid on; subplot(3,1,3); stem(0:N6-1,angle(X6),'.'); title('x6(n)的64点FFT相频'); grid on;
|


