In: Electrical Engineering
Let x[n] = cos(17?n 64 ) + 2sin(23?n 32 ) for 0 ? n ? 255, and 0 otherwise. The signal x[n] is passed through an LTI system with transfer function H(z) = (1? 1 2z?1)(1? 1 3z?1). Denote the signal at the output of the system by y[n]. We want to recover x[n] by passing y[n] through an inverse system.
(a) Find (analytically) an impulse response g[n] of the inverse system, G(z) = 1 H(z). (Note: the inverse system is an IIR system.)
(b) Apply a rectangular window of length M = 8, w[n] =( 1 0 ? n ? 7, 0 otherwise, to obtain an FIR ?lter r[n] = g[n]·w[n]. Please plot the frequency response of the FIR ?lter. Compare it with the frequency response of the IIR inverse system Is M = 8 an appropriate choice?
(c) Compute ˆ x[n] = r[n]?y[n]. Plot x[n], y[n], and ˆ x[n]?x[n].
clc;
close all;
clear all;
n = [0:1:255]; % number of samples
xn = cos(((17*pi)/64).*n)+2*sin(((23*pi)/32).*n); %defining signal
x[n]
b1 = [1 -0.833 0.166]; %Numerator coefficients of FIR filter
H(z)
a1 = 1; % denominator coefficients of FIR filter H(z)
yn = filter(b1,a1,xn); % passing x[n] signal through filter H[n]
gives y[n]
b = [1 0.833 0.527 .3 .162 .085 .0441 .022]; % Numerator filter
coefficients of FIR filter r[n]
a = 1; % denominator coefficients of FIR filter r[n]
xhat = filter(b,a,yn); % passing y[n] signal through filter r[n]
gives xhat[n]
figure %plotting x[n] y[n] xhat[n] xhat-x
subplot(2,2,1)
plot(xn,'-bs',...
'LineWidth',2,...
'MarkerSize',2,...
'MarkerFaceColor',[0,0,1])
grid on;
ylabel('xn');
subplot(2,2,2)
plot(yn,'-bs',...
'LineWidth',2,...
'MarkerSize',2,...
'MarkerFaceColor',[0,0,1])
grid on;
ylabel('yn');
subplot(2,2,3)
plot(xhat,'-bs',...
'LineWidth',2,...
'MarkerSize',2,...
'MarkerFaceColor',[0,0,1])
grid on;
ylabel('xhat');
subplot(2,2,4)
plot(xhat-xn,'-bs',...
'LineWidth',2,...
'MarkerSize',2,...
'MarkerFaceColor',[0,0,1])
grid on;
ylabel('xhat-xn');
%end of code
output: