Lab Session 12
Lab Session 12
1 INTRODUCTION
1.1 TITLE:
Fourier Transform of Square wave.
1.2 OBJECTIVES:
The objective of this experiment is to explore Fourier transform of a signal and its computation.
To gain a comprehensive understanding of how Fourier Transforms are applied to analyze
square wave signals.
2 BACKGROUND
In this lab session we have used following commands:
stem()
abs()
fft()
xlim[]
ylim[]
3 REQUIRED MATERIALS
Following is the material required to perform this specific lab :-
MATLAB
4 LAB TASKS
1. Plot the given signal as seen in lecture: with 𝑇1=1. Time scale from -10 to 10 is enough.
3. Plot Fourier transform using “fft” command, of signal found in Task 1. Plotting
right sided magnitude spectrum is enough.
5 QUESTIONS
1. What does the Fourier Transform reveal about a signal?
%MUHAMMAD AHSAN
%RP22EE402
T1 = 1; % Value of T1
t = -10:0.01:10; % Time vector
% Generate the signal x(t)
x = abs(t) < T1;
% Plot the signal
plot(t, x, 'LineWidth', 2);
ylim([-0.2, 1.2]);
xlim([-10, 10]);
xlabel('Time (t)');
ylabel('x(t)');
title('Plot of x(t)');
grid on;
6.1.1.2 OUTPUT:
6.2 PART 2
6.2.1 TASK 1
6.2.1.1 CODE TEMPLATE:
%MUHAMMAD AHSAN
%RP22EE402
w = -10:0.01:10; % Frequency vector
% Calculate the Fourier Transform
X = 2 * sin(w * T1) ./ w;
X(w == 0) = T1; % Set the value at w = 0 to T1 to avoid division by zero
% Plot the magnitude of the Fourier Transform
plot(w, abs(X), 'LineWidth', 2);
ylim([0, 2]); % Adjust ylim as needed
xlabel('Frequency (\omega)');
ylabel('|X(j\omega)|');
title('Magnitude of Fourier Transform of x(t)');
grid on;
6.2.1.2 OUTPUT:
6.3 PART 3
6.3.1 TASK 1
6.3.1.1 CODE TEMPLATE:
%MUHAMMAD AHSAN
%RP22EE402
T1 = 1; % Value of T1
t = -10:0.01:10; % Time vector
% Generate the signal x(t)
x = abs(t) < T1;
% Compute the FFT
Fs = 1 / (t(2) - t(1)); % Sampling frequency
N = length(x); % Length of the signal
X = fft(x, N); % Compute FFT
X_mag = abs(X(1:N/2+1)); % Extract right-sided magnitude spectrum
frequencies = (0:N/2) * Fs / N; % Frequency vector
% Plot the right-sided magnitude spectrum
plot(frequencies, X_mag, 'LineWidth', 2);
xlabel('Frequency (Hz)');
ylabel('|X(f)|');
title('Right-sided Magnitude Spectrum using FFT');
grid on;
6.3.1.2 OUTPUT:
7 ANSWERS
7.1 ANS 1:
The Fourier Transform reveals the frequency content of a signal by breaking it down into
individual frequencies, showing their amplitudes and phases. This allows us to analyze and
understand a signal’s composition, highlighting dominant frequencies, periodicities, and
patterns not visible in the time domain. It’s a powerful tool for uncovering structure in complex
signals, making it essential in fields like signal processing, audio analysis, and image processing.
7.2 ANS 2:
In the context of the Fourier Transform, the spectrum refers to the representation of a signal’s
frequencies and their corresponding amplitudes (and sometimes phases). It shows how the
signal's energy or power is distributed across different frequencies.
The amplitude spectrum displays the magnitude of each frequency component, indicating how
much of each frequency is present. The phase spectrum shows the phase shifts of each
frequency component. Together, these form the frequency spectrum, giving a complete view
of the signal’s frequency characteristics. This spectral information is fundamental in analyzing,
filtering, and interpreting signals across many applications, from audio processing to image
analysis.
7.3 ANS 3:
The Fast Fourier Transform (FFT) is widely used for efficient frequency analysis in signal
processing (filtering and pattern detection), image processing (compression and noise
reduction), vibration and structural analysis (resonance detection), audio and music analysis
(frequency visualization), biomedical applications (EEG/ECG analysis), and scientific
simulations (wave modeling). Its computational efficiency makes it ideal for real-time
processing and handling large datasets where fast and detailed frequency information is
essential.
8 CONCLUSION
In this experiment, the Fourier Transform of a square wave reveals that it can be represented as
a sum of sinusoidal waves with odd harmonics. The high-frequency components correspond to
the square wave’s sharp transitions, and as more harmonics are added, the wave better
approximates an ideal square shape. This demonstrates the Fourier Transform’s ability to
decompose complex signals, showcasing its value in frequency-domain analysis for
understanding signal characteristics.