% % Filename: example7.m % % Description: m-file to plot spectra of f1[k]=(.95^k)u[k] % and f2[k]=(-.95^k)u[k]. % clear; % clear matlab memory k = 0:20; % define k, f1[k], f2[k] f1 = 0.95.^k; f2 = (-0.95).^k; W = -15:0.01:15; % define W, F1(W), F2(W) F1 = 1./(1 - 0.95*exp(-j*W)); F2 = 1./(1 + 0.95*exp(-j*W)); figure(1); clf; % open and clear figure 1 subplot(3,1,1); % plot f1[k] stem(k,f1,'filled'); grid; xlabel('k'); ylabel('f_1[k]'); title('Slowly Varying DT Signal: f_1[k]=(0.95^k)u[k]'); subplot(3,1,2); % plot |F1(W)| plot(W,abs(F1)); grid; xlabel('\Omega rad'); ylabel('|F_1(\Omega)|'); title('Magnitude (Amplitude) Spectra of f_1[k]'); subplot(3,1,3); % plot /_F1(W) plot(W,angle(F1)*180.0/pi); grid; xlabel('\Omega rad'); ylabel('\angle(F_1(\Omega)) ^o'); title('Phase Spectra of f_1[k]'); figure(2); clf; % open and clear figure 2 subplot(3,1,1); % plot f2[k] stem(k,f2,'filled'); grid; xlabel('k'); ylabel('f_2[k]'); title('Fast Varying DT Signal: f_2[k]=(-0.95^k)u[k]'); subplot(3,1,2); % plot |F2(W)| plot(W,abs(F2)); grid; xlabel('\Omega rad'); ylabel('|F_2(\Omega)|'); title('Magnitude (Amplitude) Spectra of f_2[k]'); subplot(3,1,3); % plot /_F2(W) plot(W,angle(F2)*180.0/pi); grid; xlabel('\Omega rad'); ylabel('\angle(F_2(\Omega)) ^o'); title('Phase Spectra of f_2[k]');MATLAB Plots Generated: