Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

COMSATS ATD

Name: Raja Ali Dad

Reg#: FA18-EPE-174

Subject: DSP

Sessional LAB-1

Ma’am Zenab Fazal

Date; 22/10/2020
COMSATS ATD

Question: 01 10
a) Generate x (t ) and sample it. Use subplot and properly label each figure.
b) Also find fft of x (t).

x (t )=cos(2 πft)

where f= your registration number (e.g. use f=8 Hz for FA18-EPE-008)

Answer
CODE
clc
clear all
close all

f=174;
f1=1000;
t=-2:1/f1:2;
x=cos(2*pi*f*t);
n=1000;

m=linspace(-f1/2,f1/2,n);
y=fftshift(fft(x,n));
subplot 211
stem(t,x)
xlabel('Time')'
ylabel('Amplitude')
title('Sample of x(t)');

%Part b
subplot 212
plot(m,y) %fft of X(t)
xlabel('Frequency in Hz')'
ylabel('Amplitude')
title('fft of x(t)');
COMSATS ATD

Figure
Sample of x(t)
1

0.5
Amplitude

-0.5

-1
-0.48 -0.47 -0.46 -0.45 -0.44 -0.43 -0.42 -0.41 -0.4 -0.39
Time
fft of x(t)
600

400
Amplitude

200

0
-300 -200 -100 0 100 200
Frequency in Hz

Figure 1 OUTPUT

You might also like