. .
《数字信号处理》Matlab实验
一.离散信号的 FFT 分析
1.用Matlab编程上机练习。已知:
N=2^5。这里Q=0.9+j0.3。可以推导出 ,
1?QNX(k)??x(n)WN??(QWN)?,k?0,1?N?1
1?QWN kn?0n?0 首先根据这个式子计算X(k)的理论值,然后计算输入序列x(n)的32
N?1N?1 nk kn个值,再利用基2时间抽选的FFT算法,计算x(n)的DFT X(k),与X(k)的理论值比较(要求计算结果最少6位有效数字)。
解:函数代码:
>> function xn() >> format long >> q=0.9+0.3*i;
>> wn=exp(-2*pi*i/32);
>> xk=(1-q^32)./(1-q*wn.^[0:31]) >>xn=q.^[0:31] >> xk1=fft(xn,32) >>diff=xk-xk1 具体执行情况: >> function xn() format long q=0.9+0.3*i;
wn=exp(-2*pi*i/32);
xk=(1-q^32)./(1-q*wn.^[0:31]) xk =
Columns 1 through 2
0.5698 + 3.3840i 2.8369 + 8.8597i
Columns 3 through 4
9.3189 - 9.8673i 1.2052 - 3.5439i
Columns 5 through 6
1.8846 - 2.0941i 0.8299 - 1.2413i
. . .
. .
Columns 7 through 8
0.9214 - 1.0753i 0.3150 - 0.0644i
Columns 9 through 10
0.9240 - 0.8060i 0.4202 - 0.2158i
Columns 11 through 12
0.8513 - 0.6357i 0.5040 - 0.1701i
Columns 13 through 14
0.6217 - 0.6931i 0.2441 - 0.8978i
Columns 15 through 16
0.9454 - 0.2800i 0.7139 - 0.3158i
Columns 17 through 18
0.6723 - 0.6496i 0.0263 + 0.5093i
Columns 19 through 20
0.5671 + 0.6914i 0.3173 + 0.9841i
Columns 21 through 22
0.8929 + 0.7792i 0.4066 + 0.8452i
Columns 23 through 24
0.5847 + 0.9017i 0.9129 + 0.9283i
Columns 25 through 26
0.0573 + 0.5531i 0.4219 + 0.9562i
Columns 27 through 28
0.3298 + 0.3143i 0.4513 + 0.2638i
. . .
. .
Columns 29 through 30
0.7214 + 0.1879i 0.0933 + 1.7793i
Columns 31 through 32
0.9483 + 1.9802i 0.4932 + 2.6347i
>> xn=q.^[0:31] xn =
Columns 1 through 2
1.0000 0.0000 + 0.0000i
Columns 3 through 4
0.0000 + 0.0000i 0.0000 + 0.0000i
Columns 5 through 6
0.0000 + 0.0000i -0.0000 + 0.0000i
Columns 7 through 8
-0.0000 + 0.0000i -0.0000 + 0.0000i
Columns 9 through 10
-0.0000 + 0.0000i -0.0000 + 0.0000i
Columns 11 through 12
-0.0000 - 0.0000i -0.0000 - 0.0000i
Columns 13 through 14
-0.2000 - 0.4000i -0.3600 - 0.5200i
Columns 15 through 16
-0.9680 - 0.1760i 0.4816 - 0.3488i
. . .
. .
Columns 17 through 18
0.2381 - 0.2695i 0.2951 - 0.1711i
Columns 19 through 20
0.1169 - 0.4655i 0.4449 - 0.9838i
Columns 21 through 22
0.6955 + 0.2480i 0.5516 + 0.4319i
Columns 23 through 24
0.3669 + 0.5542i 0.9639 + 0.2088i
Columns 25 through 26
0.3049 + 0.9771i -0.5187 + 0.4709i
Columns 27 through 28
-0.6081 + 0.2682i -0.1278 + 0.5589i
Columns 29 through 30
-0.4827 + 0.0647i -0.6538 + 0.5134i
Columns 31 through 32
-0.8425 - 0.4341i -0.1280 - 0.1434i
>> xk1=fft(xn,32)
xk1 =
Columns 1 through 2
0.5698 + 3.3839i 2.8366 + 8.8599i
Columns 3 through 4
9.3182 - 9.8692i 1.2051 - 3.5439i
. . .
. .
Columns 5 through 6
1.8845 - 2.0942i 0.8298 - 1.2413i
Columns 7 through 8
0.9213 - 1.0754i 0.3150 - 0.0645i
Columns 9 through 10
0.9240 - 0.8060i 0.4202 - 0.2158i
Columns 11 through 12
0.8514 - 0.6356i 0.5040 - 0.1701i
Columns 13 through 14
0.6217 - 0.6931i 0.2441 - 0.8977i
Columns 15 through 16
0.9454 - 0.2800i 0.7139 - 0.3159i
Columns 17 through 18
0.6723 - 0.6496i 0.0263 + 0.5093i
Columns 19 through 20
0.5671 + 0.6913i 0.3172 + 0.9840i
Columns 21 through 22
0.8929 + 0.7792i 0.4065 + 0.8452i
Columns 23 through 24
0.5846 + 0.9016i 0.9129 + 0.9283i
Columns 25 through 26
0.0572 + 0.5531i 0.4219 + 0.9563i
. . .