MATLAB Script
clc;
clear;
close all;
% Time domain setup
Fs = 1000; % Sampling frequency
T = 1/Fs; % Sampling interval
L = 2048; % Number of samples
t = (-L/2 : L/2 -1)*T; % Symmetric time vector
% Unit step function u(t) ≈ heaviside(t)
x = double(t >= 0); % Discrete unit step
% FFT and frequency axis
X = fftshift(fft(x)); % Shift zero freq to center
f = (-Fs/2):(Fs/L):(Fs/2 - Fs/L); % Frequency vector
% Normalize FFT output
X = X / L;
% Plot time-domain signal
figure();
plot(t, x, 'LineWidth', 1.5);
title('Unit Step Function u(t)');
xlabel('Time (s)');
ylabel('Amplitude');
grid on;
xlim([-0.01 0.01]);
% Plot frequency-domain magnitude
figure();
plot(f, abs(X), 'LineWidth', 1.5);
title('Fourier Transform of a Rectangular Function');
xlabel('Frequency (Hz)');
ylabel('|X(ฯ)|');
grid on;
xlim([-50 50]);
web('https://www.salimwireless.com/search?q=fourier%20transform', '-browser');