📄 1.txt
字号:
1.编写计算有限长序列的DFT和IDFT函数
DFT的函数:
function[g,h]=dft(x,N)
n=0:N-1;k=0:N-1;
WN=exp(-j*2*pi/N);
nk=n'*k;
WNnk=WN.^nk;
X=x*WNnk;
g=abs(X);
h=angle(X)
IDFT的函数:
function [g,h]=idft(X,N);
n=0:N-1;k=0:N-1;
WN=exp(j*2*pi/N);
nk=n'*k;
WNnk=WN.^nk;
x=(X*WNnk)/N;
g=abs(x);
h=angle(x)
2.计算x=[-3 -2 3 4 2 -1 -1 2 4 3 -2 -3]
A.DFT
x=[-3 -2 3 4 2 -1 -1 2 4 3 -2 -3];N=12;
>> [g,h]=dft(x,N);
h =
Columns 1 through 6
0 -2.8798 -2.6180 0.7854 1.0472 1.3090
Columns 7 through 12
1.4601 -1.3090 -1.0472 -0.7854 2.6180 2.8798
subplot(211);stem(g);
>> subplot(212);stem(h)
B
figure;
x=[-3 -2 3 4 2 -1 -1 2 4 3 -2 -3];N=12;
n=0:N-1;
k=0:800;w=(pi/400)*k;
Xw=x*(exp(-j*pi/400)).^(n'*k);
k1=0:N-1;
WN=exp(-j*2*pi/N);
nk=n'*k1;
WNnk=WN.^nk;
X=x*WNnk;
g=abs(X)
h=angle(X)
subplot(211);
plot(w,g);
xlabel('频率');ylabel('幅度');title('12点DTFT幅度谱');
hold on;
plot([0:11]*2*pi/12,g,'o')
subplot(212);
plot(w,h);
xlabel('频率');ylabel('相位');title('12点DTFT相位谱');
hold on;
plot([0:11]*2*pi/12,h,'o');
g =
Columns 1 through 6
6.0000 10.0382 19.0526 4.2426 3.0000 2.6897
Columns 7 through 12
0.0000 2.6897 3.0000 4.2426 19.0526 10.0382
h =
Columns 1 through 6
0 -2.8798 -2.6180 0.7854 1.0472 1.3090
Columns 7 through 12
1.4601 -1.3090 -1.0472 -0.7854 2.6180 2.8798
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -