📄 dtft.m
字号:
%- discrete input signal entered as a vector
%- a scalar number indicating the position n=0 of the input vector
%- an w vector where X(w) will be calculated
function eceDTFT(inputsigna,startingpoint,w)
n=0:(length(inputsigna)-1);
n=n+startingpoint; % define the variable n for DTFT, the series x(n) begin with n=startingpoint
xn=inputsigna; % define the input signal
Xw=xn*exp(-j*n'*w) % DTFT
magx=abs(Xw); % magnitude of X(w)
angx=angle(Xw); % angle of X(w)
realx=real(Xw); % real part of X(w)
imagx=imag(Xw); % imaginary part of X(w)
subplot(2,2,1);plot(w,magx); % plot magnitude of X(w)
grid;
xlabel('w');title('magnitude of X(w)');ylabel('magnitude');
subplot(2,2,2);plot(w,angx); % plot angle of X(w)
grid;
xlabel('w');title('angle of X(w)');ylabel('angle');
subplot(2,2,3);plot(w,realx); % plot real part of X(w)
grid;
xlabel('w');title('real part of X(w)');ylabel('ReX(w) ');
subplot(2,2,4);plot(w,imagx); % plot imaginary part of X(w)
grid;
xlabel('w');title('imaginary part of X(w)');ylabel('ImX(w) ') ;
En=abs(xn)*(abs(xn))' % the energy of the signal in time domain
Ew= sum(Xw.*conj( Xw))/(2.*pi) % the energy of the signal in the frequency domain
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -