p2_a4.m

来自「Digital Signal Processing-A Computer-Bas」· M 代码 · 共 18 行

M
18
字号
% Program P2_A4
% Evaluation of the DTFT 
close all ; clear all;
% Compute the frequency samples of the DTFT
w = -4*pi:8*pi/511:4*pi;
num = [1 3 5 7 9 11 13 15 17];
h = freqz(num, 1, w);
% Plot the DTFT
subplot(2,1,1);plot(w/pi,real(h));grid;title('Real part of H(e^{j\omega})')
xlabel('\omega /\pi');ylabel('Amplitude');
subplot(2,1,2);plot(w/pi,imag(h));grid;title('Imaginary part of H(e^{j\omega})')
xlabel('\omega /\pi');ylabel('Amplitude');
figure
subplot(2,1,1);plot(w/pi,abs(h));grid;title('Magnitude Spectrum |H(e^{j\omega})|')
xlabel('\omega /\pi');ylabel('Amplitude');
subplot(2,1,2);plot(w/pi,angle(h));grid;title('Phase Spectrum arg[H(e^{j\omega})]')
xlabel('\omega /\pi');ylabel('Phase in radians');

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?