Task-01: Discrete Time Fourier Transform
Task-01: Discrete Time Fourier Transform
Task-01: Discrete Time Fourier Transform
The DTFT, the Fourier transform that relates an aperiodic, discrete signal, with a
periodic, continuous frequency spectrum. The DTFT is often used to analyze
samples of a continuous function.
MATLAB Implementation:
close all
clear all
clc
%%%%%%%%%%%%%%%%%%%% Exercise-01 %%%%%%%%%%%%%%%%%%%%%%%
syms n;
syms omega;
x = rectangularPulse(0,5,n); % initializing a Rectangular pulse
figure('Name','Task-01----"Discrete Time Fourier Transform" ')
subplot(3,1,1)
fplot(x,[-30 30])
title('Representation of signal in given range')
xlabel('n')
ylabel('x')
grid
% Finding DTFT of the signal
tic
F = symsum((x*exp(-j*omega*n)),n,-30,30)
toc
X = abs(F) % ignoring all complex values, gives magnitudes only
subplot(3,1,2)
fplot(X,[-10*pi 10*pi])
title('DTFT, Fourier Domain Representation')
xlabel('omega')
ylabel('X(omega)')
grid
% Fourier Domain Representation for one period
subplot(3,1,3)
fplot(X, [-3 3])
title('Fourier domain representation for one period, centered at 0')
xlabel('omega')
ylabel('X(omega)')
grid
%%%%%%%%%%%%%%%%%%%%%% Exercise-02 %%%%%%%%%%%%%%%%%%%%%%%
y1 = x;
fs = 1;
t = -30:1/fs:30;
y =double(subs(y1,n,t)); % defining a signal, by substitution
figure('Name','Task-02----"DFT using FFT" ')
subplot(3,1,1)
stem(t,y)
title('Input Signal')
xlabel('t')
ylabel('y')
grid
% Fourier Transform
L =length(t);
n = 2^nextpow2(L) % Defining N samples
tic
Z = fft(y,n)/fs;
toc
P = abs(Z);
Y1 =fftshift(P); % finding fast fourier transform
f =-fs/2:fs/n:(fs/2)-(fs/n);
subplot(3,1,2)
plot(f,Y1)
%plot(f,Y1)
title('DFT using FFT')
xlabel('f')
ylabel('Y(f)')
grid
Plot:
Task-01:
Explanation:
A rectangular pulse is defined for specific range as was given in a piecewise
function. First of all, I calculated DTFT of a signal, by using symsum function.We
obtained a signal with periodic continuous frequency spectrum.In task-01, period
for frequency domain waveform is -30 to 30, for defined range as given. In task 02,
we substituted t, which was defined for a specific range. Then by using fft
command, we found fast fourier transform. And also we used fftshift command to
shift signal centered at zero. In fft shift function N samples were taken as power of
2. I found out N, by first calculating length of t. The more we take samples, value
of N, the more accurate result we obtained in Frequency range.
Question/Answer:
Q: Change the sampling frequency and N in your code, and write your
observations about the effect on the input and output plots.
Ans: By increasing sampling frequency, the inputs points (samples) become more
and more, and output just compress to center without leaving any effect on
Amplitude. As, I obtained n, by finding length of t, and t is defined with respect to
fs. So, when I increase fs, n also increases (number of samples).
On the other hand, when I increase n, number of samples increases in input side
and if a rectangular pulse is taken as input as here, it is compressed to center (like a
unit impulse) at zero. Output remains same.
Q: Provide screenshots of the output, and explain which algorithm took more
time and why?
Ans: Discrete Fourier Transform, DFT, is the algorithm that transforms the time
domain signals to the frequency domain components. Fast Fourier Transform, FFT,
is a computational algorithm that reduces the computing time and complexity of
large transforms. So, time taken in computing fft is less than dft.
This can be shown from figure given below:
From this figure, we can see that time taken by fft is less than dft. That means fft is
efficient algorithm for computing discrete fourier transform.
Conclusion:
When we deal with time domain analysis, and want to analyze signal in frequency
domain analysis, we do fourier transform. And, also, we relate aperiodic discrete
time fourier transform with periodic continuous frequency spectrum in DTFT.
Moreover, for getting accurate result in less time, we perform FFT to find out
Discrete fourier transform. Because, it reduces the computing time and complexity
of large transforms.
The Fast Fourier Transform is basically a fast algorithm for computing the discrete
Fourier transform of a sequence. The Fourier transform has various properties
which allow for simplification of ODEs and PDEs (ordinary differential equation
and Partial differential equation).
----------------------------------------------------------------------------------------------------
The End