Experiement-8
Fourier Transform of a given signal
Aim: To write the MATLAB code for plotting magnitude and phase spectrum of Fourier
transform for the following functions.
1. Exponentialfunction
2. Gatefunction
3. Gaussianfunction
4. Triangularfunction
EQUIPMENTS:
Operating System – Windows XP
Constructor - Simulator
Software - MATLAB 2012a
Theory:
A periodic signal defined for −∞ <t <∞ or a signaldefined in a closed time interval a ≤ t ≤ b
can be expanded in a Fourier series, as a linear combination of infinite sinusoidal signals.
The Fourier seriesexpansion reveals the frequency content of a signal. The Fourier
transform is the way to express any signal definedin the time domain for −∞ <t <∞ in
thefrequency domain.The Fouriertransform is denoted by the symbol F {.} ; and is defined
as
∞
X ( ω )=F { x ( t ) }= ∫ x (t)e
− jωt
dt
−∞
In order to return from the frequency domain back to the time domain the inverse
Fouriertransform is applied. The inverse Fourier transform is denoted by the symbol F−1 {.} ;
and is defined as
∞
1
x (t )=F { X ( ω ) }=
−1
∫
2 π −∞
jωt
X (ω)e dt
In MATLAB there is the possibility to compute directly the Fourier transform X (ω) of a
signal x (t ) by using the command fourier. Correspondingly, the inverse Fourier transform is
computed by using the command ifourier. Before executing these two commands, time t
and frequency ω must be declared as symbolic variables.
Program
clc;
clear all;
close all;
% Fourier Transform of a Continuous-Time Signal with Phase Spectrum
clc;
clear;
close all;
% Define the time vector
t = -5:0.01:5; % Time range
x_t = rectpuls(t, 2); % Rectangular pulse of width 2
% Plot the original signal
figure;
subplot(3,1,1);
plot(t, x_t, 'LineWidth', 1.5);
xlabel('Time (t)');
ylabel('Amplitude');
title('Original Signal x(t)');
grid on;
% Fourier Transform
f = linspace(-10, 10, 1000); % Frequency range
X_f = zeros(size(f)); % Initialize Fourier Transform
% Perform the Fourier Transform
for k = 1:length(f)
X_f(k) = trapz(t, x_t .* exp(-1j * 2 * pi * f(k) * t));
end
% Calculate Magnitude and Phase
magnitude_X_f = abs(X_f);
phase_X_f = angle(X_f);
% Plot the magnitude of the Fourier Transform
subplot(3,1,2);
plot(f, magnitude_X_f, 'LineWidth', 1.5);
xlabel('Frequency (Hz)');
ylabel('|X(f)|');
title('Magnitude Spectrum of x(t)');
grid on;
% Plot the phase of the Fourier Transform
subplot(3,1,3);
plot(f, phase_X_f, 'LineWidth', 1.5);
xlabel('Frequency (Hz)');
ylabel('Phase (radians)');
title('Phase Spectrum of x(t)');
grid on;
Result: Fourier transform for Gate pulse is calculated and plotted the magnitude and phase
spectrum