0% found this document useful (0 votes)
66 views5 pages

S&S Lab 100

This document is a laboratory manual on implementing the discrete Fourier transform (DFT) and inverse DFT using MATLAB. It discusses using the fft and ifft commands to compute the DFT and inverse DFT of a signal respectively. It also discusses implementing the DFT and inverse DFT using the formulas directly. The document also covers sampling and aliasing, demonstrating these concepts using MATLAB code and analyzing the effects of different sampling frequencies on a sinusoidal signal.

Uploaded by

Fakhar Abbaspp
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
66 views5 pages

S&S Lab 100

This document is a laboratory manual on implementing the discrete Fourier transform (DFT) and inverse DFT using MATLAB. It discusses using the fft and ifft commands to compute the DFT and inverse DFT of a signal respectively. It also discusses implementing the DFT and inverse DFT using the formulas directly. The document also covers sampling and aliasing, demonstrating these concepts using MATLAB code and analyzing the effects of different sampling frequencies on a sinusoidal signal.

Uploaded by

Fakhar Abbaspp
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Signals and Systems

(EL-223)

LABORATORY MANUAL

Dr.Shahzad Saleem
Engr. Fakhar Abbas
Implementatin of DFT and IDFT using MATLAB
(LAB # 13)

____________________________________________________________________________________________________________________________________________________________

NATIONAL UNIVERSITY OF COMPUTER AND EMERGING SCIENCES, ISLAMABAD

Prepared by: Engr. Fakhar Abbas Version: 1.00


Last Edited by:
Verified by: Dr. Waqas bin Abbas, Dr. Shahzad Updated: Spring 2020
Saleem
Implementatin of DFT and IDFT using MATLAB Lab 13

Lab # 13: Implementatin of DFT and IDFT using MATLAB


Objective: In this lab, you will learn:
 How to find DFT and inverse DFT:
 Using fft and ifft command
 Using Formula implementation
 Sampling and Aliasing using MATLAB
 Analysis of fft command over different points
 Filtering applied to Audio Signals
Tools Used: MATLAB

Description:

DFT:
The discrete Fourier transform, or DFT, is the primary tool of digital signal processing. The
foundation of the product is the fast Fourier transform (FFT), a method for computing the DFT with
reduced execution time. Many of the toolbox functions (including Z-domain frequency response,
spectrum and cepstrum analysis, and some filter design and implementation functions) incorporate
the FFT. DFT and Inverse DFT are represented as:

DFT and IDFT computations using usign fft and ifft commands in MATLAB:

Example: x[n] = [ −3 4 1 2]
fft:
fft(x) computes the discrete Fourier transform (DFT) of X using a fast Fourier transform (FFT)
algorithm

ifft:
ifft(X) returns the inverse discrete Fourier transform (IDFT) of vector X, computed with a fast
Fourier transform (FFT) algorithm. If X is a matrix, ifftreturns the inverse DFT of each column of the
matrix.

Example:
x = [3 4 1 -2] % Defining x[n]
XK = fft(x)% Computing DFT
xn = ifft(XK)% Computing IDFT
Note: You can also compute DFT and IDFT using formula given above that would also give same
results as fft and ifft command.

SIGNALS AND SYSTEMS LAB NUCES FAST, ISLAMABAD Page 2 of 5


Implementatin of DFT and IDFT using MATLAB Lab 13

Sampling and Aliasing:


The sampling theorem states that a band-limited continuous-time signal, with highest frequency (or
bandwidth) equal to B Hz, can be recovered from its samples provided that the sampling frequency,
denoted by Fs, is greater than or equal to 2B Hz (or samples per second). The minimum sampling
rate is often called the Nyquist rate. For example, the minimum sampling rate for a telephone speech
signal (assumed low-pass filtered at 4 kHz) should be 8 KHz (or 8000 samples per second), while the
minimum sampling rate for an audio CD signal with frequencies up to 22 KHz should be 44KHz.

In the figure below, you see the sampling effects on a sinusoidal signal of frequency B Hz that result
from the use of different sampling frequencies.

Sampling of a continuous-time signal results in repeating its spectrum in the frequency domain. The
spectrum is repeated every Fs Hz. Assuming that the bandwidth of the continuous-time signal is B
Hz, then the repeated bands in the frequency domain will not interfere with each other if the sampling
frequency is larger than 2B Hz. In this case, the spectrum of the original signal can be recovered from
the spectrum of the sampled signal by low-pass filtering with a cutoff frequency that is equal to Fs/2
Hz. This also means that the original signal can be recovered from the sampled signal via the low-
pass filtering operation. When the sampling rate is not large enough (not larger than 2B Hz), then
interference among adjacent bands will occur, and this results in the phenomenon of aliasing. In this
case, the original signal cannot be recovered from the sampled signal

Sampling and Aliasing Phenomenon using MATLAB:

Example: Compting Magnitude Spectrum of DFT.

SIGNALS AND SYSTEMS LAB NUCES FAST, ISLAMABAD Page 3 of 5


Implementatin of DFT and IDFT using MATLAB Lab 13

Matlab Code of above Example:

clc;close;
Fs = 10; %sampling Frequency
f = 2; % Signal’s Frequency
N = 10; % Total number of samples
n = 0:N-1; % n represents sample number
T = 1/Fs; % T represents sampling interval i.e., time between 2
samples
t = n*T; % t = nTs = n/Fs
x2 = cos(2*f*pi*t);
Xk = fft(x2); % Computing fft
Y = abs(Xk);
X = fftshift(abs(Xk));
fx = 0:Fs/length(X):Fs-(Fs/length(X));
fy = -Fs/2:Fs/length(X):Fs/2-(Fs/length(X));
subplot(311)
h=stem(fx,Y,'filled');
set(gca,'Xtick',0:13,'fontweight','bold')
set(h,'linewidth',2);
grid on;
xlabel('0 to Fs - 1','fontweight','bold');
ylabel('|X(k)|','fontweight','bold')
title('Before fftshift')
subplot(312)
h=stem(fx,X,'filled');
set(gca,'Xtick',0:13,'fontweight','bold');

SIGNALS AND SYSTEMS LAB NUCES FAST, ISLAMABAD Page 4 of 5


Implementatin of DFT and IDFT using MATLAB Lab 13

set(h,'linewidth',2);
grid on;
xlabel(' 0 to Fs - 1','fontweight','bold');
ylabel('|X(k)|','fontweight','bold');
title('After fftshift');
subplot(313)
h=stem(fy,X,'filled');
set(gca,'Xtick',-7:7,'fontweight','bold');
set(h,'linewidth',2);
grid on;
xlabel('-Fs/2 to Fs/2','fontweight','bold');
ylabel('|X(k)|','fontweight','bold');
title('After fftshift');

SIGNALS AND SYSTEMS LAB NUCES FAST, ISLAMABAD Page 5 of 5

You might also like