0% found this document useful (0 votes)
24 views5 pages

DSP Lab Report !

The document contains MATLAB code that plots the equations of a low pass filter and a high pass filter in the time and frequency domains. The code generates input signal x, defines low pass filter h1 and high pass filter h2, takes the convolution of x with each filter to produce outputs y1 and y2, and plots the signals and filters in both domains across two figures with 9 subplots each.

Uploaded by

Innam Ullah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views5 pages

DSP Lab Report !

The document contains MATLAB code that plots the equations of a low pass filter and a high pass filter in the time and frequency domains. The code generates input signal x, defines low pass filter h1 and high pass filter h2, takes the convolution of x with each filter to produce outputs y1 and y2, and plots the signals and filters in both domains across two figures with 9 subplots each.

Uploaded by

Innam Ullah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Name: Innamullah Azhar

REG# 17PWELE5110
Lab# 01
Subject: DSP
Submitted to: Sir Gul Muhammad
TITLE:
Plot the Equation in MATLAB

Code:
n = -20:20;

figure('name','Low pass filter');

h1 = (n==0)+(n==1);

subplot(3,3,1);
stem(n,h1), title("h1 time domain");

h1f = fftshift(fft(ifftshift(h1)));

subplot(3,3,2);
stem(n,abs(h1f)), title("h1 magnitude in frequency domain");
subplot(3,3,3);
stem(n,angle(h1f)),title("h1 phase in frequency domain");

x = 10 + 20*cos(0.5*pi*n +pi/4)+ 10*cos(pi*n);

subplot(3,3,4);
stem(n,x),title("x time domain");

xf = fftshift(fft(ifftshift(x))) /10;

subplot(3,3,5);
stem(n, abs(xf)),title("x magnitude in freq domain");
subplot(3,3,6);
stem(n, angle(xf)),title("x phase in freq domain");

y1 = conv(x,h1);

subplot(3,3,7);
stem(linspace(-20,20,81),y1),title("y1 time domain");

y1f = fftshift(fft(ifftshift(y1))) /10;

subplot(3,3,8);
stem(linspace(-20,20,81),abs(y1f)),title("y1 magnitude in frequency
domain");
subplot(3,3,9);
stem(linspace(-20,20,81),angle(y1f)),title("y1 phase in frequency
domain");

figure('name','High pass filter');

h2 = (n==0)-1*(n==1);

subplot(3,3,1);
stem(n,h2),title("h2 time domain");

h2f = fftshift(fft(ifftshift(h2)));

subplot(3,3,2);
stem(n,abs(h2f)),title("h2 magnitude in frequency domain");
subplot(3,3,3);
stem(n,angle(h2f)),title("h2 phase in frequency domain");

subplot(3,3,4);
stem(n,x),title("x time domain");
subplot(3,3,5);
stem(n, abs(xf)),title("x magnitude in frequency domain");
subplot(3,3,6);
stem(n, angle(xf)),title("x phase in frequency domain");

y2 = conv(x,h2);

subplot(3,3,7);
stem(linspace(-20,20,81),y2),title("y2 time domain");

y2f = fftshift(fft(ifftshift(y2))) /10;

subplot(3,3,8);
stem(linspace(-20,20,81),abs(y2f)),title("y2 magnitude in frequency
domain");
subplot(3,3,9);
stem(linspace(-20,20,81),angle(y2f)),title("y2 phase in frequency
domain");

FIGURE#1
FIGURE#2

You might also like