Exp-8 Fourier Transform
Exp-8 Fourier Transform
EXPERIMENT NO: 8
Fourier Transform and Analysis of Fourier Spectrum
Aim:
1. To determine the Fourier transform of any signal and reconstruct again using MATLAB
2. To analyze the signal using Fourier spectrum.
Software Used:
MATLAB 2024a
Theory:
Fourier Transform is a mathematical model which helps to transform the signals between
two different domains, such as transforming signal from frequency domain to time domain or vice
versa. Fourier transform has many applications in Engineering and Physics, such as signal processing,
RADAR, and so on.
The generalization of the complex Fourier series is known as the Fourier transform. The term
“Fourier transform” can be used in the mathematical function, and it is also used in the representation
of the frequency domain. The Fourier transform helps to extend the Fourier series to the non-periodic
functions, which helps us to view any functions in terms of the sum of simple sinusoids.
1. Fourier Transform
The Fourier Transform (FT) decomposes a signal into its constituent frequencies, providing a
frequency-domain representation.
𝑋(𝑓) = 𝑥(𝑡)𝑒 𝑑𝑡
𝑥(𝑡) = 𝑋(𝑓)𝑒 𝑑𝑓
Where:
𝑋(𝑓): Frequency-domain representation.
𝑥(𝑡): Time-domain signal.
𝑓: Frequency.
The first equation here is the Forward Fourier transform. It converts the function of time (t)
into the function of frequency (𝑓). The second equation is Inverse Fourier transform. It does the
opposite to first equation i.e. it converts the function of frequency (𝑓) into the function of time (t).
2. Fourier Spectrum
The Fourier spectrum represents the magnitude and phase of 𝑋(𝑓), providing insight into the
signal's frequency content.
Magnitude Spectrum
|𝑋(𝑓)| = 𝑅𝑒(𝑋(𝑓)) + 𝐼𝑚(𝑋(𝑓))
Phase Spectrum
𝐼𝑚(𝑋(𝑓))
∠𝑋(𝑓) = tan−1
𝑅𝑒(𝑋(𝑓))
Experimental Procedure:
1. Start the MATLAB program.
2. Create a NEW M-File from the file Menu.
3. An editor window open, type the program in it.
4. Save the file in current directory.
5. Compile and Run the program.
6. If any error occurs in the program correct the error and run it again.
7. For the output see command window\ Figure window.
SOURCE CODE:
clc; clear; close all;
%% Parameters
f0 = 5; % Frequency of sinusoid (Hz)
T = 1 / f0; % One period of the sinusoid
Fs = 1000; % Sampling frequency (for numerical integration)
t = linspace(0, 2*T, Fs); % Time vector restricted to two cycles
f = linspace(-50, 50, Fs); % Frequency vector
%% Define Time-Domain Signal (Sinusoidal)
x_t = cos(2*pi*f0*t); % Sinusoidal signal
%% Compute Fourier Transform using Integral Definition
X_f = zeros(size(f)); % Initialize Fourier Transform result
for k = 1:length(f)
X_f(k) = trapz(t, x_t .* exp(-1j*2*pi*f(k)*t));
% Numerical Integration
end
%% Compute Inverse Fourier Transform
x_t_reconstructed = zeros(size(t));
for k = 1:length(t)
x_t_reconstructed(k) = trapz(f, X_f .* exp(1j*2*pi*f*t(k)));
% Numerical Integration
end
x_t_reconstructed = x_t_reconstructed / max(abs(x_t_reconstructed));
% Normalize for visualization
x_t_reconstructed = real(x_t_reconstructed); % Remove imaginary part
%% Plot Results
figure;
% Original Time-Domain Signal
subplot(4,1,1);
plot(t, x_t, 'b', 'LineWidth', 1.5);
title('Original Time-Domain Signal x(t)');
xlabel('Time (s)');
ylabel('Amplitude');
grid on;
% Magnitude Spectrum
subplot(4,1,2);
plot(f, abs(X_f), 'r', 'LineWidth', 1.5);
title('Magnitude Spectrum |X(f)|');
xlabel('Frequency (Hz)');
ylabel('Magnitude');
grid on;
% Phase Spectrum
subplot(4,1,3);
plot(f, angle(X_f), 'k', 'LineWidth', 1.5);
title('Phase Spectrum \angle X(f)');
xlabel('Frequency (Hz)');
ylabel('Phase (radians)');
grid on;
% Reconstructed Time-Domain Signal
subplot(4,1,4);
plot(t, x_t_reconstructed, 'r--', 'LineWidth', 1.5);
title('Reconstructed Time-Domain Signal x(t) from Inverse Fourier
Transform');
xlabel('Time (s)');
ylabel('Amplitude');
grid on;
% Display the plots
sgtitle('Fourier Transform and Inverse Fourier Transform of a Sinusoidal
Signal');
OUTPUT:
RESULT: