Practical 7: Performing Fourier Transforms
Objective: To understand and perform Fourier Transforms on various signals
using MATLAB, and to analyze the magnitude and phase responses.
Fourier Transform of Unit Impulse
Explanation: The unit impulse function, denoted by δ(t), is a fundamental
signal in signal processing. The Fourier Transform of the unit impulse gives us
insight into how this signal behaves in the frequency domain.
Steps:
1. Define the symbolic variable and the unit impulse function using the dirac
function.
2. Compute the Fourier Transform using the fourier function.
3. Plot the real and imaginary parts of the Fourier Transform using ezplot.
MATLAB Code:
% Define the symbolic variable and unit impulse
function
syms t ;
delta_t = dirac ( t ) ;
% Compute the Fourier Transform
Delta_w = fourier ( delta_t , t ) ;
% Plot the real and imaginary parts of the Fourier
Transform
figure ;
subplot (2 , 1 , 1) ;
ezplot ( real ( Delta_w ) , [ -10 , 10]) ;
xlabel ( ’ Frequency ( w ) ’) ;
ylabel ( ’ Real ( Delta ( w ) ) ’) ;
title ( ’ Real Part of Fourier Transform of delta ( t ) ’) ;
grid on ;
xlim ([ -10 , 10]) ; % Adjust x - axis limits
1
subplot (2 , 1 , 2) ;
ezplot ( imag ( Delta_w ) , [ -10 , 10]) ;
xlabel ( ’ Frequency ( w ) ’) ;
ylabel ( ’ Imag ( Delta ( w ) ) ’) ;
title ( ’ Imaginary Part of Fourier Transform of delta ( t )
’) ;
grid on ;
xlim ([ -10 , 10]) ; % Adjust x - axis limits
Fourier Transform of Unit Step
Explanation: The unit step function, denoted by u(t), is another basic signal
in signal processing. Its Fourier Transform helps in understanding the frequency
content of signals that turn on at a specific time.
Steps:
1. Define the time domain signal using the heaviside function.
2. Compute the Fourier Transform symbolically.
3. Display the symbolic Fourier Transform expression.
4. Compute the magnitude and phase responses.
5. Plot the magnitude and phase responses.
MATLAB Code:
% Define the time domain signal
syms t ;
u = heaviside ( t ) ;
% Compute the Fourier transform symbolically
syms omega ;
U_omega = fourier (u , t , omega ) ;
% Display the symbolic Fourier transform expression
with ’i ’ for the imaginary unit
disp ( ’ Fourier Transform Expression : ’) ;
disp ( U_omega ) ;
% Define frequency values for plotting
omega_values = linspace ( -10 , 10 , 1000) ; % Adjust the
range as needed
% Compute magnitude and phase responses for the given
frequency range
2
U_magnitude = abs ( subs ( U_omega , omega , omega_values ) ) ;
U_phase = angle ( subs ( U_omega , omega , omega_values ) ) ;
% Plot magnitude response
subplot (2 , 1 , 1) ;
plot ( omega_values , U_magnitude ) ;
title ( ’ Magnitude Response ’) ;
xlabel ( ’ Frequency ( omega ) ’) ;
ylabel ( ’ Magnitude ’) ;
% Plot phase response
subplot (2 , 1 , 2) ;
plot ( omega_values , U_phase ) ;
title ( ’ Phase Response ’) ;
xlabel ( ’ Frequency ( omega ) ’) ;
ylabel ( ’ Phase ( radians ) ’) ;
Fourier Transform of Rectangular Pulse
Explanation: A rectangular pulse is a common signal used in digital communi-
cation and signal processing. Its Fourier Transform provides information about
the signal’s spectral components.
Steps:
1. Define the rectangular pulse signal symbolically using the heaviside func-
tion.
2. Compute the Fourier Transform symbolically.
3. Display the symbolic Fourier Transform expression.
4. Compute the magnitude and phase responses.
5. Plot the magnitude and phase responses.
MATLAB Code:
% Define symbolic time variable
syms t ;
% Define the rectangular pulse signal symbolically
using Heaviside
rect_pulse = heaviside ( t + 1) - heaviside ( t - 1) ;
% Compute the Fourier transform symbolically
syms omega ;
U_omega_rect = fourier ( rect_pulse , t , omega ) ;
3
% Display the symbolic Fourier transform expression
disp ( ’ Fourier Transform of Rectangular Pulse
Expression : ’) ;
disp ( U_omega_rect ) ;
% Define frequency values for plotting
omega_values = linspace ( -10 , 10 , 1000) ; % Adjust the
range as needed
% Compute magnitude and phase responses for the given
frequency range
U_magnitude_rect = abs ( subs ( U_omega_rect , omega ,
omega_values ) ) ;
U_phase_rect = angle ( subs ( U_omega_rect , omega ,
omega_values ) ) ;
% Plot magnitude response
subplot (2 , 1 , 1) ;
plot ( omega_values , U_magnitude_rect ) ;
title ( ’ Magnitude Response ’) ;
xlabel ( ’ Frequency ( omega ) ’) ;
ylabel ( ’ Magnitude ’) ;
% Plot phase response
subplot (2 , 1 , 2) ;
plot ( omega_values , U_phase_rect ) ;
title ( ’ Phase Response ’) ;
xlabel ( ’ Frequency ( omega ) ’) ;
ylabel ( ’ Phase ( radians ) ’) ;
Response of an LTI System Using Fourier Trans-
form
Explanation: The response of a Linear Time-Invariant (LTI) system can be
determined using the Fourier Transform of its impulse response and the input
signal. This practical demonstrates how to compute the response in both the
time and frequency domains.
Steps:
1. Define the input signal and impulse response using symbolic variables.
2. Compute the Fourier Transform of both the input signal and impulse
response.
4
3. Multiply the Fourier Transforms to get the output in the frequency do-
main.
4. Compute the inverse Fourier Transform to obtain the time-domain re-
sponse.
5. Plot the input signal, impulse response, and the system’s response in both
time and frequency domains.
MATLAB Code:
clc ;
close all ;
clear all ;
% Define the input signal and impulse response
syms t ;
x = 2* exp ( -5* t ) * heaviside ( t ) ;
X = fourier ( x ) ;
h = 2* exp ( -3* t ) * heaviside ( t ) ;
H = fourier ( h ) ;
% Compute the output in the frequency domain
Y = X * H;
% Compute the inverse Fourier Transform to obtain the
time - domain response
y = ifourier (Y , t ) ;
% Plot the input signal ( time - domain )
subplot (3 , 2 , 1) ;
ezplot (x , [ -3 , 3]) ;
ylim ([0 2]) ;
title ( ’ Input ( Time - domain ) ’) ;
grid on ;
% Plot the input signal ( frequency - domain )
subplot (3 , 2 , 2) ;
ezplot ( abs ( X ) , [ -15 , 15]) ;
title ( ’ Input ( Frequency - domain ) ’) ;
grid on ;
% Plot the impulse response ( time - domain )
subplot (3 , 2 , 3) ;
ezplot (h , [ -3 , 3]) ;
ylim ([0 2]) ;
title ( ’ Impulse Response ( Time - domain ) ’) ;
5
grid on ;
% Plot the impulse response ( frequency - domain )
subplot (3 , 2 , 4) ;
ezplot ( abs ( H ) , [ -15 , 15]) ;
title ( ’ Impulse Response ( Frequency - domain ) ’) ;
grid on ;
% Plot the system ’ s response ( time - domain )
subplot (3 , 2 , 5) ;
ezplot (y , [ -3 , 3]) ;
ylim ([0 2]) ;
title ( ’ Response ( Time - domain ) ’) ;
grid on ;
% Plot the system ’ s response ( frequency - domain )
subplot (3 , 2 , 6) ;
ezplot ( abs ( Y ) , [ -15 , 15]) ;
title ( ’ Response ( Frequency - domain ) ’) ;
grid on ;
Explanation of New Functions Used
syms: This function is used to define symbolic variables in MATLAB. Sym-
bolic variables allow us to perform algebraic operations, calculus, and other
mathematical computations symbolically rather than numerically.
fourier: This function computes the Fourier Transform of a symbolic ex-
pression. It transforms a time-domain signal into its frequency-domain repre-
sentation.
ifourier: This function computes the inverse Fourier Transform of a sym-
bolic expression, transforming a frequency-domain signal back into the time
domain.
dirac: This function is used to represent the Dirac delta function (unit
impulse) symbolically.
heaviside: This function represents the Heaviside step function, which is
commonly used to model signals that switch on at a certain point in time.