% % Filename: example11.m % % Description: m-file to plot magnitude spectrum of p5[n] % clear; clf; W = -3*pi:0.01:3*pi; % define DT frequencies Xa = 1 + 2*cos(W) + 2*cos(2*W); % plot |X(W)| from cosines subplot(2,1,1); plot(W,abs(Xa)); xlabel('WMATLAB Plot Generated:'); ylabel('|X(W)|'); title('DTFT of p5[n] (from sum of cosines)'); Xb = sin(2.5*W)./sin(W/2); % plot |X(W)| sinc-like function subplot(2,1,2); plot(W,abs(Xb)); xlabel('W '); ylabel('|X(W)|'); title('DTFT of p5[n] (from sinc-like function)');