0% found this document useful (0 votes)
105 views

Laboratory Manual 4: Discrete Time Fourier Transform & Discrete Fourier Transform

The laboratory manual covers tasks involving the discrete time Fourier transform (DTFT) and discrete Fourier transform (DFT). The tasks include plotting signals in the time and frequency domains, observing the effect of increasing N in an N-point DFT, analyzing sine waves and noise signals, and recording and transforming a voice signal. Code and plots are provided for each task, with explanations of the transforms and differences between the tasks.

Uploaded by

Hassan
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
105 views

Laboratory Manual 4: Discrete Time Fourier Transform & Discrete Fourier Transform

The laboratory manual covers tasks involving the discrete time Fourier transform (DTFT) and discrete Fourier transform (DFT). The tasks include plotting signals in the time and frequency domains, observing the effect of increasing N in an N-point DFT, analyzing sine waves and noise signals, and recording and transforming a voice signal. Code and plots are provided for each task, with explanations of the transforms and differences between the tasks.

Uploaded by

Hassan
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10

Name: Hassan Tariq Majeed

Roll # : 14F-8355

Section : A

Laboratory Manual 4
Discrete Time Fourier Transform

&

Discrete Fourier Transform


Lab Objective:

The tasks given in the lab 7 include:

 Familiarization with Discrete Time Fourier Transform


 Familiarization with Discrete Fourier Transform

Tools used:

MATLAB

Description:

Discrete Time Fourier Transform:


Discrete Fourier Transform:
For each task you have to plot each signal in time domain across its time vector and then plot its
frequency spectrum both using fft(x) and fft(x,N) across its respective frequency vectors. You have to
give the complete explanation for each task separately in which you will also explain for each task that
what’s the difference of increasing N in N point fftand at the end you have to compare all tasks.

Task0:

Plot the signal z in time domain with Fs=1000?

x=[0 1 0 5 7 6 3 4 7 1 9 8 7 8 3 2]

Code:
clc
clearall
fs=1000
ts=1/(fs)
x=[0 1 0 5 7 6 3 4 7 1 9 8 7 8 3 2]
t=0:ts:0.015
plot (t,x,'r')
xlabel('time (t)' )
ylabel('Amplitude')
title('Time Domain Signal')

Explanation:

< Insert your explanation here>

Task 1:

Plot frequency spectrum of x=[1 1 1 0 0]; Fs=1000; across its frequency vector with fft(x) and fft(x,N). See the
difference by increasing N and explain it.

Code:
clc
clearall
x=[1 1 1 0 0]
l=length(x)
fs=1000
ts=1/fs
t=0:ts:4*ts
subplot(221)
stem(t,x,'r')
xlabel('time (t)' )
ylabel('Amplitude')
title('Signal in Time domain')

n=1024
y=fft(x,n)
t1=(0:(length(y)-1))*(fs/length(y))
subplot(222)
stem(t1,y,'r')
xlabel('Omega (w)' )
ylabel('Amp')
title('Fourier Transform')
y1=fft(x,n)
subplot(223)
stem(t1,abs(y1),'r')
xlabel('Omega (w)' )
ylabel('Amp')
title('Fourier Transform Magnitude')
p=angle(y)
subplot(224)
stem(t1,p,'r')
xlabel('Omega (w)' )
ylabel('Amp')
title('Fourier Transform Magnitude Angle')

Plot (s) (time domain + frequency domain):


Explanation:

First of all , I made the signal in time domain. Then I took discrete time fourier transform of signal. I
took the magnitude and phase spectrum.

Task 2:

Observe the frequency spectrum of the signal A?

A=sin(2*pi*440*(0:1/8000:0.5));

sound(A,8000);

Code:
clc
clearall
t=0:1/8000:0.5
a=sin(2*pi*440*t)
fs=8000
subplot(331)
plot(t,a,'r')
xlabel('time (t)' )
ylabel('Amplitude')
title('Signal in Time domain')

y=fft(a)
y1=length(y)
t1=(0:(length(y)-1))*(fs/y1)
subplot(332)
stem(t1,y,'r')
xlabel('Omega (w)' )
ylabel('Amp')
title('Fourier Transform')

y1=fft(a)
subplot(223)
stem(t1,abs(y1),'r')
xlabel('Omega (w)' )
ylabel('Amp')
title('Fourier Transform Magnitude')

p=angle(y1)
subplot(224)
stem(t1,p,'r')
xlabel('Omega (w)' )
ylabel('Amp')
title('Fourier Transform Magnitude Angle')
Plot (s) (time domain + frequency domain):

Explanation:

First of all , I made the signal in time domain. Then I took discrete time fourier transform of signal. I
took the magnitude and phase spectrum.

Task 3:

Load chirp.mat file and observe the frequency spectrum?

Code:
clearall
clc
clearall
loadchirp.mat
x=y'
fs=8000
ts=1/(fs)

t=(0:length(x)-1)*ts
sound(x,fs)
subplot(221)
plot (t,x,'r')
xlabel('time (t)' )
ylabel('Amplitude')
title('Chirp Signal')

y=fft(x)
subplot(222)
stem(t,y,'r')
xlabel('Frequency (f)' )
ylabel('Amplitude')
title('Chirp Signal in Frequency Domain')
y1=fft(x)
subplot(223)
stem(t,abs(y1),'r')
xlabel('Omega (w)' )
ylabel('Amplitude')
title('Chirp signal Magnitude')

p=angle(y)
subplot(224)
stem(t,p,'r')
xlabel('Omega (w)' )
ylabel('Amplitude')
title('Chirp Signal Angle')

Plot (s) (time domain + frequency domain):

Explanation:

First I made a chirp signal by loading Chip.mat file. Then I draw chirp signal in frequency domain.
Then I took magnitude and phase spectrum.

Task 4:

Form a signal S containing a 50 Hz sinusoid of amplitude 0.7 and a 120 Hz sinusoid of amplitude 1. Corrupt the
signal with zero-mean white noise with a variance of 4.

X = S + 2*randn(size(t));

Listen both signals and observe the frequency spectrum of both S and X?

Fs=1000;
Length of signal = L =1000;

Code:
clearall
clc
clearall

fs=1000
ts=1/fs
t=0:ts:999;
f=50;
l=1000;
a=0.7;
x=a.*sin(2*pi*f*t);

a1=1;
f1=120;
x1=a1.*sin(2*pi*f1*t);
s=x+x1;

y=fft(s);
y1=abs(y);
subplot(221);
plot(t,y1);
xlabel('time (t)' );
ylabel('Amplitude');
title('Magnitude of spectrum sum of 2 signal');

b=s+2*randn(size(t));
subplot(222);
plot(t,b);
xlabel('time (t)' );
ylabel('Amplitude');
title('Noisy signal ');

b1=fft(b)
subplot(223);
plot(t,b);
xlabel('time (t)' );
ylabel('Amplitude');
title('Noisy signal fft');

b2=abs(b);
subplot(224);
plot(t,b2);
xlabel('time (t)' );
ylabel('Amplitude');
title('Magnitude of Noisy signal');

Plot (s) (time domain + frequency domain):


Explanation:

First of all, I add two different signals. Then I made a noisy signal and add with the sum of two signals.
Then I took its magnitude and phase in frequency domain.

Task 5:

Record your own voice and observe the frequency spectrum?

myvoice=audiorecorder;

recordblocking(myvoice,5);

play(myvoice);

Y=getaudiodata(myvoice);

Code:

< Insert program code here. Copy from m-file(s) and paste. >

Plot (s) (time domain + frequency domain):

< Insert program plot here. Copy from Matlab figure and paste. >

Explanation:

< Insert your explanation here>


Task 6:

Compare all task and explain?

Ans: In all the task, First of all I draw the signal in time domain. Then I take its discrete time fourier transform
(DTFT). I also observe the signal in frequency domain by magnitude and phase of signal.

Date:_______________ Signature:_______________

You might also like