Lab 6
Lab 6
C O N T E N T S:
Frequency Response of LTI System: .......................................................................................... 2
Steady State Response of LTI System: ....................................................................................... 2
Frequency Response by using Difference Equation ................................................................... 3
LAB TASKS: .............................................................................................................................. 5
1
Frequency Response of LTI System:
The discrete time Fourier Transform of an impulse response of LTI system is called the Frequency
Response of an LTI system and is denoted by
𝐻(𝑒 𝑗𝑤 ) = ∑∞
𝑛=−∞ ℎ(𝑛)𝑒
−𝑗𝑤𝑛
... (1)
We can represent the system by
Hence the output sequence is the input exponential sequence modified by the response of the system at the
frequency 𝑤0 .
In general, the frequency response 𝐻(𝑒 𝑗𝑤 ) is a complex function of 𝑤. The magnitude |𝐻(𝑒 𝑗𝑤 )| of 𝐻(𝑒 𝑗𝑤 ) is
called the magnitude response function and the angle ∠𝐻(𝑒 𝑗𝑤 ) is called the phase response function.
Program 1:
Determine the frequency response 𝐻(𝑒 𝑗𝑤 ) of a system characterized by
ℎ(𝑛) = (0.9)𝑛 𝑢(𝑛)
Plot the magnitude and phase response.
Using Eq. 1, we find that
1
𝐻(𝑒 𝑗𝑤 ) = ... (2)
1−0.9𝑒 −𝑗𝑤
>> w=[0:pi/500:pi]; % just to make 500 samples of pi
>> H=1./(1-0.9*exp(-j*w));
>> magH=abs(H); >> angH=angle(H);
>> subplot(211) >> plot(w,magH)
>> subplot(212) >> plot(w,angH)
Program 2:
Determine the steady state response 𝑦𝑠𝑠 (𝑛) of the system characterized by
ℎ(𝑛) = (0.9)𝑛 𝑢(𝑛) 0 ≤𝑛 ≤ 10
when the input to the system is
𝑥 (𝑛) = 3cos(0.5𝜋𝑛 + 60𝑜 )
From Program 1 we know that for this system, the frequency response is
2
1
𝐻(𝑒 𝑗𝑤 ) =
1 − 0.9𝑒 −𝑗𝑤
>> n=0:10; >> w0=0.5*pi;
>> theta=60; >> A=3;
>> H0=1./(1-0.9*exp(-j*w0));
>> magH0=abs(H0);
>> angH0=angle(H0);
>> yss=A*magH0*cos(w0*n+ theta + angH0);
>> plot(n,yss)
Alternate Method
From Eq. 2, we find the difference equation parameters and then use filter command to find the output of the
system.
>> b=[1]; >> a=[1,-0.9];
>> n=0:10;
>> x=3*cos(0.5*pi*n +60);
>> yss=filter(b,a,x);
>> plot(n,yss)
3
1
𝐻(𝑒 𝑗𝑤 ) =
1−0.8𝑒 −𝑗𝑤
b-
>> b=[1]; >> a=[1,-0.8];
>> n=0:100;
>> x=cos(0.05*pi*n);
>> y=filter(b,a,x);
>> plot(n,y)
In the above example, the system was characterized by a first-order difference equation. In practice the
difference equations are of large order and hence we need a compact procedure. This can be done using a
simple matrix-vector multiplication. If we evaluate 𝐻(𝑒 𝑗𝑤 ) at k=0,1,…,K equispaced frequencies over [0, 𝜋],
then Eq. 2 will be
∑𝑀 𝑏 𝑒 −𝑗𝑤𝑘 𝑚
𝐻(𝑒 𝑗𝑤𝑘 ) = 𝑚=0𝑁 𝑚 −𝑗𝑤𝑘𝑙 , 𝑘 = 0,1, … , 𝐾
1+ ∑𝑙=1 𝑎𝑙 𝑒
If we let {𝑏𝑚 }, {𝑎𝑙 } (with 𝑎0 = 1) , m=0,1,…,M , l=0,1,…,N and {𝑤𝑘 } be arrays (or row vectors), then the
numerator and denominator of above equations become
𝒃𝑒𝑥𝑝(−𝑗𝒎𝑇 𝒘) 𝑎𝑛𝑑 𝒂𝑒𝑥𝑝(−𝑗𝒍𝑇 𝒘)
This procedure can be implemented in MATLAB to define the frequency response, given the difference
equations parameters.
Program 4:
An LTI system is described by:
𝑦(𝑛) = 0.0181𝑥(𝑛) + 0.0543𝑥(𝑛 − 1) + 0.0543𝑥(𝑛 − 2) + 0.0181𝑥(𝑛 − 3)
+ 1.76𝑦(𝑛 − 1) − 1.1829𝑦(𝑛 − 2) + 0.2781𝑦(𝑛 − 3)
>> b = [0.0181,0.0543,0.0543,0.0181];
>> a = [1,-1.76,1.1829,-0.2781];
>> m=0: length(b)-1; >> l=0:length(a)-1;
>> K=500; >> k=0:K;
>> w=[0:0.00628:pi];
>> num=b*exp(-j*m'*w);
>> den=a*exp(-j*l'*w);
>> H=num./den;
>> magH=abs(H); >> angH=angle(H);
>> subplot(211) >> plot(w,magH)
4
>> subplot(212) >> plot(w,angH)
Write MATLAB code to plot the magnitude response and phase response to describe the frequency response of
the system.
Task 2: Let 𝑥(𝑛) = 2𝑠𝑖𝑛(0.3𝜋𝑛) be the input to the LTI system given by
Write MATLAB code to detect the steady state response of the system by analyzing the frequency response.
𝑥(𝑛) − 𝑥(𝑛 − 1)
𝑦(𝑛) − 𝑦(𝑛 − 1) =
2
a- Write MATLAB code to describe the impulse response of system in frequency domain and plot the
frequency response.
b- Write MATLAB code to detect the steady state response of the system to the input
𝜋
𝑥(𝑛) = 5 + cos(0.5𝜋𝑛 + )
2