dft.m
来自「经典《信号与系统》教程的matlab例程,对深入理解信号与系统相关概念有很大帮助」· M 代码 · 共 39 行
M
39 行
N=input('Type in the period N:');
M=input('Type in the length M:');
n=-N:2*N;
x=(u(n)-u(n-M));
xs=(u(n+N)-u(n-M+N))+(u(n)-u(n-M))+(u(n-N)-u(n-M-N))+(u(n-2*N)-u(n-M-2*N));
subplot(221)
stem(n,x,'.')
title('The curve of sequence x(n)')
%xlabel('Index n')
%ylabel('The amplitude of x(n)')
subplot(223)
stem(n,xs,'.')
title('The periodic sequence xs(n) from x(n)')
xlabel('Index n')
%ylabel('The amplitude of xs(n)')
k=0:N;
w1=2*pi/N;
w=k*w1;
F=x*exp(-j*n'*w);
subplot(224)
stem(k,abs(F),'r.')
axis([0,N,0,max(abs(F))])
xlabel('Index w')
title('The DFT of x(n)')
W1=1*pi;
N=512;
k=0:2*N;
W=k*W1/(N);
F=x*exp(-j*n'*W);
F1=abs(F);
subplot(2,2,2);plot(k/(2*N),F1);
title('The DTFT of x(n) ');
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?