Experiment Lab Report 5

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

United International University

Dept. of Electrical & Electronic Engineering (EEE)

Fall 2022
DIGITAL SIGNAL PROCESSING
LABORATORY EEE 3310
Lab Report – 5

Submitted to:
Dr. Khawza Iftekhar Uddin Ahmed

Submitted by:
GROUP 1

Name ID

Joyanta Debnath 021 182 032

Ranjan Kumer Sarker 021 191 027

Shakib Hasan 021 201 054

Mushfiqul Hoque 021 201 103

Date of Performance: 19th October 2022


Date of Submission: 3rd November 2022
Lab Report - 2
Discrete Fourier Transform (DFT) using MATLAB

Introduction: From this lab session-05 we get to know about Discrete Fourier Transform
(DFT), Inverse Discrete Fourier Transform (IDFT), Fast Fourier Transform(FFT) and finally
we implement some examples on MATLAB of these topics

Theoretical Background: The DFT is a strong tool in DSP which actually enables us to find
the spectrum of a finite duration signal. In DFT, here we convert a discrete time signal, time
domain to frequency domain. Similarly, IDFT does the opposite of DFT.

On Fast Fourier Transform (FFT), MATLAB provides this function called “fft”. Suppose if we
want to run a code which has lot of loops then it will take some time to run the code but If we
use “fft” then it will take less time and run the coder firstly.

In Lab Evaluation:
1. A 12-point sequence x(n) is defined as
x (n)= {1,2,3,4,5,6,6,5,4,3,2,1}
Determine the DFT of x(n). Plot it’s magnitude and phase

Code:
x = [1, 2, 3, 4, 5, 6, 6, 5, 4, 3, 2, 1]; n=0:11; N = 12;
X = dft(x,N);
magX = abs(X), phaX = angle(X)*180/pi
subplot(211);stem(n,magX,'k');title('Magnitude')
subplot(212);stem(n,phaX,'k');title('Angle')

Page 2 of 9
2. Let x(n)= (0.5)n 0<n<7
(a) Determine and plot x((-n))8
(b) Determine DFT of the circularly shifted sequence.

Code:
%a
n = 0:7; x = (0.5) .^ n;
y = x(mod(-n,8)+1); % Try to see values in "mod(-n,8)"
subplot(2,1,1); stem(n,x); title('Original sequence')
xlabel('n'); ylabel('x(n)');
subplot(2,1,2); stem(n,y); title('Circularly folded
sequence')
xlabel('n'); ylabel('x(-n mod 8)');
%b
X = dft(x,8); Y = dft(y,8);
figure
subplot(2,2,1); stem(n,real(X));
title('Real{DFT[x(n)]}'); xlabel('k');
subplot(2,2,2); stem(n,imag(X));
title('Imag{DFT[x(n)]}'); xlabel('k');
subplot(2,2,3); stem(n,real(Y));
title('Real{DFT[x((-n))8]}'); xlabel('k');
subplot(2,2,4); stem(n,imag(Y));

Page 3 of 9
title('Imag{DFT[x((-n))8]}'); xlabel('k');

Page 4 of 9
Homework:
1. Correlation is an effective method of detecting signals buried in noise. Noise are
essentially uncorrelated. This means that, if we correlate a noisy signal with
itself, the correlation will be only due to the signal only. This will exhibit a sharp
peak at n=0. Generate two noisy signals by adding noise to a 20Hz sinusoid
sampled at Ts=0.01 sec for 1 seconds.
(a) Verify the presence of the signal by plotting correlation of the two
noisy signals.
(b) Can you see the presence of periodicity in correlation plot? Where it
coming from?
(c) Plot FFT spectrum of the correlation.
(d) Can you see the original sinusoid frequency in the FFT?

Code:

t = 0:0.001:1;
x = sin(2*pi*20*t);
Y= x + .2*rand(size(x));
Z= x + .2*rand(size(x));
X1= xcorr(Y,Z);
X2=fft(X1);
figure

Page 5 of 9
subplot(211);
plot(X1);
title('xcorr signal');
subplot(212);
plot(abs(X2));
title('FFT signal')

Page 6 of 9
DISCRIPTION: Here we did generate two noisy sinusoidal signal and then tried to create a
correlation signal (xcorr) whose period is same to the original signal.

2. During transmission, a message signal gets contaminated by a low-frequency


signal and high-frequency noise. The message can be decoded only by displaying
it in the time domain. The contaminated signal x[n] is provided at server-7 as
mystery1.mat. Load this signal into MATLAB (use the command load mystery1).
In an effort to decode the message, try the following procedure and determine
what the decoded message says.
(a) Display the contaminated signal. Can you “read” the message?
(b) Display the DFT of the signal to identify the range of the message
spectrum.
(c) First zero out the DFT component corresponding to the low-frequency
contamination and obtain its IDFT y[n].
(d) Next, zero out the DFT component corresponding to the high-
frequency contamination and obtain its IDFT y[n].
(e) Take the IDFT to obtain the filtered signal and display it to decode the
message.

Code:

%a
load mystery1;figure
plot(mystery1);
title('Original ECG');
%b
x=fft(mystery1,length(mystery1-1));
figure
plot(abs(x));
title('fft of Originl mystery1');
size(x)
%c,d&e
j=[1:100 201:1200 1301:1400];
y=x;
y(j)=0;
z=ifft(y);
figure
plot(abs(z));
title('message signal');

Page 7 of 9
Page 8 of 9
DISCRIPTION: Here, we did try to generate a message signal which got contaminated by
the low frequency signal and high frequency noise. The message decoded in the time domain
to displayed. Then we did take the IDFT to get the filtered signal & display it to decode the
message.

Statement: I Have contributed and given my full support in completing this report.

Page 9 of 9

You might also like