p2_g.m
来自「Digital Signal Processing-A Computer-Bas」· M 代码 · 共 27 行
M
27 行
% Program P2_G.m
% Evaluation of the DFT
close all ; clear all;
% 7-length sequence
n=[-3:3];
x=cos(pi*n/6);
% Compute the M-point DFT
M=8;
X=fft(x,M);
% Plot the original sequence
figure(1)
t=-3:1:3;
stem(t,x);grid
xlabel('Time index n');ylabel('Magnitude')
title('Original time-domain sequence')
% Plot the magnitude and phase of the DFT
figure(2)
subplot(2,1,1)
k=0:1:M-1;
stem(k,abs(X));grid
xlabel('Frequency index k');ylabel('Magnitude')
title('The magnitude of the DFT')
subplot(2,1,2)
stem(k,angle(X));grid
xlabel('Frequency index k');ylabel('Phase')
title('The phase of the DFT')
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?