In: Electrical Engineering
For all the requested figures below, use a discrete time range
of n = [0,50] on the x-axis. Remember your script should be
self-sufficient and run without any errors to receive any
points.
You are given a discrete time system (1) below (same system as
Homework 5(a)):
(E - 0.2)(E - 0.4)(E - 0.6) y[n] = (2 - 3E)
x[n]
(1)
Question 1. Compute the impulse response h[n] of system (1) above,
using the recursive solution method. You will not receive any
points for using another method. Given the system input x[n]
defined by equation (2) below, compute the output yr[n] to the
system (1), using h[n] you have just computed and x[n], by discrete
convolution. You will not receive any points for computing yr[n]
using another method.
x[n] = cos( pi x n/32)
u[n]
(2)
Display computed yr[n] together with y[n] you have computed in
Homework 5(a) on the same figure. Display yr[n] in red circles
(‘ro’), and y[n] in blue stars (‘b+’). You are NOT asked to display
h[n], do NOT display h[n]. Do not forget to properly label and
annotate your figure and follow the time range requirement set on
the top of this page. You will not receive full points
otherwise.
Note: Use a stem plot, with the help of the built in Matlab
function “stem()” in order to properly represent a discrete signal
on a figure.
Solution
a)The impulse response is calculated recursively by using the given difference equation.
b)x(n) is convolved with the impulse response which is obtained from (a) to find the system response y(n).
c)plotted the input and the output.
MATLAB:
clc;close all;clear all;
%E=delay Ey(n) means y(n-1)
n=0:1:50
b=conv(conv([1,-0.2],[1,-0.4]),[1 -0.6])%To obtain the coeffients
of y(n) terms
a=[-3 2]%coefficients of x(n)
%compute Impulse response
x= (n==0)%define impulse function
y=zeros(1,length(n))
%Initial conditions
y(1)=0
y(2)=0
y(3) = 0;
x(4)=1%Initail value of del(n)
%Recursive implementation
for m=4:1:length(n)
y(m)=(-b(1)*y(m-3)-b(2)*y(m-2)-b(3)*y(m-1)+2*x(m)-3*x(m-1))/b(4)
end
h=y%h(n)
%compute yr(n)
x= cos(pi*n/32).*(n>=0)
y=conv(x,h)
m=0:1:100
subplot(211)
stem(n,x,'b')
xlabel('n')
ylabel('x(n)')
title('x(n)')
subplot(212)
stem(m,y/max(abs(y)),'m')
xlabel('n')
ylabel('y(n)')
title('y(n)')
______________________________________________________________