Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The impulse response of a LTI system is h (n) = [(0.5)^n + (0.4)^n] u (n). Deter

ID: 2082590 • Letter: T

Question

The impulse response of a LTI system is h (n) = [(0.5)^n + (0.4)^n] u (n). Determine the frequency response H (w) and plots its magnitude and phase response over the interval [-pi, pi]. Use the DTFT function that I have provided to compute the frequency response. Let x (n) = 3 cos (0.5 pi n + 60 degree) + 2 sin (0.3 pi n) be the input to the above LTI system. Determine the output y (n). You can use the filter function in MATLAB. Comment on the output. function [X] = dtft(x, n, w) % Computes Discrete-time Fourier Transform % [X] = dtft(x, n, w) % X = DTFT values are computed at w frequencies % x = finite duration sequence over n % n = sample position vector % w = frequency location vector X = x*exp(-1i*pi/(length(w)-l)).^(n'*(w*(length(w)-1)/pi)); ONLY USE MATLAB CODE.

Explanation / Answer

Copy the following code to a new function file in MATLAB. Name the file dtft.m

function [X] = dtft(x,n,w)
% Computes Discrete-time Fourier Transform
%[X] = dtft(x,n,w)
% X = DTFT values are computer at w frequencies
% x = finite duration sequence over n
% n = sample position vector
% w = frequency location vector
X = x*exp(-1i*pi/(length(w)-1)).^(n'*(w*(length(w)-1)/pi));

end

Copy the following code to a new script file in MATLAB.

clear all; close all; clc;
% Part (a)
n = 0:199;
N = length(n);
h = 0.5.^n + 0.4.^n;
w = linspace(-pi,pi,N);
H = dtft(h,n,w);
figure; subplot(2,1,1); plot(w,abs(H)); axis tight
title('Frequency response H(omega)');
xlabel('omega');ylabel('|H(omega)|');
subplot(2,1,2); plot(w,angle(H)*180/pi); axis tight
xlabel('omega');ylabel('ngleH(omega) (degrees)');

% Part (b)
x = 3*cos(0.5*pi*n+60*pi/180)+2*sin(0.3*pi*n);
b = [2 -0.9]; % coefficients of numerator polynomial - from picture
a = [1 -0.9 0.2]; % coefficients of denominator polynomial - from picture
y = filter(b,a,x);
figure; subplot(2,1,1); stem(n,x,'.');
title('Input x[n]');xlabel('n');ylabel('Amplitude');
subplot(2,1,2); stem(n,y,'.');
title('Output y[n]');xlabel('n');ylabel('Amplitude');