dtft的函数的编写
function [X]=dtft(x,n,w)
X=x*exp(-j*n'*w)
例题1
n=-50:50
x1=(n>=0)
x21=(0.8).^n ; x2=x21.*x1
subplot(3,1,1);stem(n,x1,'.')
subplot(3,1,2);stem(n,x2,'.')
例题2
n=-100:100
x=(n>=-2)&(n<2)
w=-2*pi:0.01:2*pi
X=dtft(x,n,w)
subplot(3,2,1)
plot(w,abs(X)) %幅度频谱
subplot(3,2,2)
plot(w,angle(X))%相位频谱
%----------------
n=-100:100
x11=(n>=-2)&(n<2)
x12=exp(-j*0.65*pi*n) %x(n)exp(-j*0.65*pi*n)
x=x11.*x12
w=-2*pi:0.01:2*pi
X=dtft(x,n,w)
subplot(3,2,3)
plot(w,abs(X)) %幅度频谱
subplot(3,2,4)
plot(w,angle(X))%相位频谱
%------------------
n=-100:100
x=(n>=0)&(n<4) %x(n-2)
w=-2*pi:0.01:2*pi
X=dtft(x,n,w)
subplot(3,2,5)
plot(w,abs(X)) %幅度频谱
subplot(