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

DSP

LAB REPORT # 6

Sampling and multi-rate signal processing:


decimation and interpolation

Submitted By:

Marryam Nawaz
SP-12-BET-043

Hifza Sajid
SP-12-BET-029

Submitted To:
Sir Mobeen Sabir

Class Instructor:
Sumayya Haroon

Class:
BET-5A
Dated:
21/03/2014
Use your ‘sinegen’ function to generate a sine wave with f = 3kHz and fs = 8kHz.
Calculate its fft with zero frequency component in the middle. Plot it on a
properly scaled w-axis.

CODE:

t=-5:0.01:5;
y=sin(2*pi*30*t);
Y=fft(y,80);
subplot(2,1,1)
plot(y),grid on
title('Sine Wave')
subplot(2,1,2)
plot(Y),grid on
title('FFT')

GRAPH:

Sine Wave
1

0.5

-0.5

-1
0 200 400 600 800 1000 1200

FFT
40

20

-20

-40
-1 -0.5 0 0.5 1 1.5 2 2.5 3 3.5 4
-12
x 10
Sine Wave
1

-1
0 200 400 600 800 1000 1200
FFT
50

-50
-1 -0.5 0 0.5 1 1.5 2 2.5 3 3.5 4
-12
x 10
Downsampler Signal
20

-20
-1 -0.5 0 0.5 1 1.5
-12
x 10

Decimate the signal in task 1 with ‘M = 2’ and plot the resultant signal. Give your
observations about the plots in your reports

CODE:

t=-5:0.01:5;
y=sin(2*pi*30*t);
Y=fft(y,80);
subplot(3,1,1)
plot(y),grid on
title('Sine Wave')
subplot(3,1,2)
plot(Y),grid on
title('FFT')
subplot(3,1,3)
z=decimate(Y,2);
plot(z),grid on
title('Downsampler Signal')

GRAPH:
Repeat task 2 for following signals:
 x1[n] = cos(2*pi*f0/fs*n)+cos(2*pi*f1/fs*n)
o f0 = 2kHz; f1 = 6kHz; fs = 10kHz;
 x2[n] = cos(2*pi*f0/fs*n)+cos(2*pi*f1/fs*n)+ cos(2*pi*f1/fs*n)
o f0 = 2kHz; f1 = 4kHz; f2 = 3kHz; fs = 10kHz;

CODE:

n=-5:5;
f0 = 2; f1 = 6; fs = 10;
y= cos(2*pi*f0/fs*n)+cos(2*pi*f1/fs*n);
Y=fft(y,80);
subplot(3,1,1)
plot(y),grid on
title('Sine Wave')
subplot(3,1,2)
plot(Y),grid on
title('FFT')
subplot(3,1,3)
z=decimate(Y,2);
plot(z),grid on
title('Downsampler Signal')

GRAPH:
Sine Wave
2

-1
1 2 3 4 5 6 7 8 9 10 11
FFT
5

-5
-1 0 1 2 3 4 5 6 7
Downsampler Signal
5

-5
-1 0 1 2 3 4 5 6 7

CODE:

n=-5:5;
f0 = 2; f1 = 4;f2=3;fs = 10;
y= cos(2*pi*f0/fs*n)+cos(2*pi*f1/fs*n)+ cos(2*pi*f1/fs*n)
Y=fft(y,80);
subplot(3,1,1)
plot(y),grid on
title('Sine Wave')
subplot(3,1,2)
plot(Y),grid on
title('FFT')
subplot(3,1,3)
z=decimate(Y,2);
plot(z),grid on
title('Downsampler Signal')

GRAPH:

Sine Wave
4

-2
1 2 3 4 5 6 7 8 9 10 11
FFT
10

-10
-6 -4 -2 0 2 4 6
Downsampler Signal
10

-10
-4 -3 -2 -1 0 1 2 3 4 5 6
Explain which components will be aliased & why?

For 1stsignal :

Fmax=6KHZ &Fs=10KHz
As Fs !> 2Fmax
So it contain aliasing.

For 2nd signal :

Fmax=4KHZ &Fs=10KHz
As Fs> 2Fmax
So it does contain aliasing.

Assignment Task

CODE:

t=-5:0.14:5;
f0 = 2; f1 = 4;f2=6;f3=8;f4=10;fs = 10;
y= cos(2*pi*f0/fs*t)+cos(2*pi*f1/fs*t)+ cos(2*pi*f2/fs*t)+ cos(2*pi*f3/fs*t)+ cos(2*pi*f4/fs*t)
Y=fft(y,80);
subplot(4,1,1)
plot(y),grid on
title('COS Wave')
subplot(4,1,2)
plot(Y),grid on
title('FFT')
subplot(4,1,3)
z=decimate(Y,3);
plot(z),grid on
title('Downsampler Signal')
subplot(4,1,4)
Z=interp(z,4);
plot(Z),grid on
title('Upsempler Signal')

GRAPH:
COS Wave
5

-5
0 10 20 30 FFT
40 50 60 70 80
50

-50
-20 -10 0 Downsampler
10 Signal 20 30 40
20

-20
-5 0 5 10 15 20
Upsempler Signal
20

-20
-5 0 5 10 15 20

You might also like