Labsheet1 EAC22065

Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

19EAC283 Digital Signal Processing & Processors Lab

Ex.No:1
Ex.Name: DFT and IDFT
Name of the student: Vinayakan Sajeev
Reg.No:AM.EN.U4EAC22065

Objective:

Evaluation:
19EAC283 Digital Signal Processing & Processors Lab

Ex_1: Generate 320 samples of a 50Hz sine wave sampled at 8KHz and multiply this by a1KHz
sine wave sampled at 8KHz. Plot the resulting waveform.
CODE:
t=(0:320)/8000;
x1=sin(2*pi*50*t);x2=sin(2*pi*1000*t);
subplot(3,1,1)
stem(x1)
xlabel('t')
ylabel('x(t)')
title('sine of 50hz');
subplot(3,1,2)
stem(x2)
xlabel('t')
ylabel('x(t)')
title('sine of 1khz');
fin=x1.*x2;
subplot(3,1,3)
stem(fin)
xlabel('t')
ylabel('x(t)')
title('product signal');
OUTPUT:

Ex_2: Generate and plot the signal x(t) = 3cos(20πt)−2sin(30πt) over a time range of 0 < t
< 400msec. Also plot the DT signal formed by sampling this function at the following
sampling intervals:

Based on your results, what can you say about how fast this signal should be sampled so
that it could be reconstructed from the samples?
CODE:
close all;clear all;clc
19EAC283 Digital Signal Processing & Processors Lab

t=0:1/800:0.4;
x=3*cos(20*pi*t)-2*sin(30*pi*t);
plot(t,x)
xlabel('t');
ylabel('x(t)');
title('original');
figure;
subplot(4,2,1)
t=0:1/120:0.4;
x=3*cos(20*pi*t)-2*sin(30*pi*t);
plot(t,x)
xlabel('t');
ylabel('x(t)');
title('ts=1/120')
subplot(4,2,2);
stem(t,x)
subplot(4,2,3)
t=0:1/60:0.4;
x=3*cos(20*pi*t)-2*sin(30*pi*t);
plot(t,x)
xlabel('t');
ylabel('x(t)');
title('ts=1/60')
subplot(4,2,4);
stem(t,x)
subplot(4,2,5)
t=0:1/30:0.4;
x=3*cos(20*pi*t)-2*sin(30*pi*t);
plot(t,x)
xlabel('t');
ylabel('x(t)');
title('ts=1/30')
subplot(4,2,6);
stem(t,x)
subplot(4,2,7)
t=0:1/15:0.4;
x=3*cos(20*pi*t)-2*sin(30*pi*t);
plot(t,x)
xlabel('t');
ylabel('x(t)');
title('ts=1/15')
subplot(4,2,8);
stem(t,x)

Ex_3: Sample the CT signal x(t) = sin(2πt) at a sampling rate fs. Then, using MATLAB,
plot the interpolation between samples in the time range −1 < t < 1 using the
approximation:
19EAC283 Digital Signal Processing & Processors Lab

(a) fs= 4, fc = 2, N = 2

(b) fs= 16, fc = 8, N = 16


(c) fs= 8, fc = 4, N = 4
CODE:
clear all;close all;clc;
t=-1:0.01:1;
x=sin(2*pi*t);
subplot(4,1,1)
plot(t,x)
xlabel('t');
ylabel('x(t)');
title('Original');
y1=zeros(1,length(t));
N=2;
fc=2;
fs=4;
ts=1/fs;
for i=1:length(t)
for n=-N:N
y1(i)=y1(i)+2*(fc/fs)*sin(2*pi*n*ts)*sinc(2*fc*(t(i)-n*ts));
end
end
subplot(4,1,2);
plot(t,y1)
xlabel('t');
ylabel('x(t)');
title('fs=4,fc=2;N=2')
y2=zeros(1,length(t));
N=16;
fc=8;
fs=16;
ts=1/fs;
for i=1:length(t)
for n=-N:N
y2(i)=y2(i)+2*(fc/fs)*sin(2*pi*n*ts)*sinc(2*fc*(t(i)-n*ts));
end
end
subplot(4,1,3);
plot(t,y2)
xlabel('t');
ylabel('x(t)');
title('fs=16,fc=8,N=16')
y3=zeros(1,length(t));
N=4;
fc=4;
fs=8;
ts=1/fs;
for i=1:length(t)
for n=-N:N
19EAC283 Digital Signal Processing & Processors Lab

y3(i)=y3(i)+2*(fc/fs)*sin(2*pi*n*ts)*sinc(2*fc*(t(i)-n*ts));
end
end
subplot(4,1,4);
plot(t,y3)
xlabel('t');
ylabel('x(t)');
title('fs=16,fc=8,N=4')
OUTPUT

INFERENCE: The concept of sampling of signals has been explained in the experiments. We can infer from
them about the concept of Nyqist rate and Nyquist interval, which is essesntial in sampling
a signal accurately. Differences in reconstructed signals with different sampling frequency
and number of samples can be clearly identified form the graphs plotted. We have also looked
at multiplication of signals and have visually seen from the graph how it would be. The optimal
rate at which a signal should be sampled is also understood after this experiment.
Evaluator Name:

Signature with date:

You might also like