DSP Lab Report 7 Oel
DSP Lab Report 7 Oel
frequency domain
OPEN ENDED LAB
5 / 3 / 24
07
EE-20-A
Equipment’s:
• Laptop
• MATLAB (software)
Introduction to MATLAB
MATLAB is a high-level programming language that has been used extensively to solve complex
engineering problems.
Task
An LTI system is specified by the difference equation.
1. Write MATLAB code to describe the impulse response of system in frequency domain and plot the
frequency response.
2. Write MATLAB code to detect the steady state response of the system to the input.
Answers:
Following is the MATLAB function code as well as the results.
part i
clc;
clear;
b = [0.5, -0.5]; % input(x) coefficients
a = [1, -1]; % output(y) coefficients
m = 0 : length(b)-1;
l = 0 : length(a)-1;
k = 500; % samples
K = 0 : k;
w = 0: pi/k :pi;
num=b*exp(-1i*m'*w);
den=a*exp(-1i*l'*w);
H=num./den;
magH=abs(H);
angH=angle(H);
subplot(211); plot(w,magH,LineWidth=4); title magnitute ;xlabel w ;ylabel amplitute;legend
magnitute;
subplot(212); plot(w,angH,LineWidth=4); title Phase ;xlabel w ;ylabel amplitute;legend
phase;
figure
plot(H,LineWidth=4); title Impulse(H(exp(-jwn))) ;xlabel n ;ylabel amplitute;legend H;
part ii
%let n be
n = -20:0.1:20;
A = 2;
B = 5;
wo = 0.5*pi;
theta = pi/2;
k = 500;
w = 0:pi/k:wo;
x = B + A*cos(wo*n + theta);
yss = B.*magH(1:length(n)) + A.*magH(1:length(n)).*cos(wo*n+theta+angH(1:length(n)));
anglyss = angle(yss);
magyss = abs(yss);
plot(n,x,LineWidth=4);title x;xlabel n;ylabel amplitute;legend input;
…the end!