📄 dtft.m
字号:
%==========================================================================
% Name:DTFT.m
% The program compute the DTFT of discrete-time sequence x(n),
% and plot the curves.
%==========================================================================
clear;
p=input('1--close;2--open,please select the form of the sequence x(n):');
while p~=1&p~=2
p=input('Please reselect the form of the sequence x(n):');
end
if p==1
n=-10:10;
f=input('Type in the expression of sequence x(n):');
end
if p==2
f=input('Type in the vector of sequence x(n):');
n=input('Type in the index of sequence x(n):');
end
W1=4*pi;
N=512;
k=-N:N;
W=k*W1/(N);
F=f*exp(-j*n'*W);
F1=abs(F);
phi=57.3*angle(F);
subplot(221);stem(n,f,'.');grid on;
xlabel('Index n');title('the curve of x(n)');
subplot(222);plot(W,F1);grid on;
title('The DTFT of the sequence x(n)');
ylabel('The magnitude spectra ');
subplot(224);
plot(W,phi,'r');grid on;
xlabel('w');ylabel('The phase spectra');
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -