% Define parameters
Fs = 1000; % Sampling frequency in Hz
T = 1/Fs; % Sampling period in seconds
L = 1000; % Length of the signal
t = (0:L-1)*T; % Time vector
% Define the function (sine wave in this case)
f = 5; % Frequency of the sine wave in Hz
y = sin(2 * pi * f * t); % Generate sine wave
% Compute Fourier Transform
Y = fft(y); % Fast Fourier Transform
P2 = abs(Y/L); % Two-sided spectrum
P1 = P2(1:L/2+1); % Single-sided spectrum
P1(2:end-1) = 2*P1(2:end-1);
% Define frequency domain
f = Fs*(0:(L/2))/L;
% Plotting
figure;
subplot(2,1,1);
plot(t, y);
title('Original Signal (Sine Wave)');
xlabel('Time (s)');
ylabel('Amplitude');
subplot(2,1,2);
plot(f, P1);
title('Fourier Transform of the Signal');
xlabel('Frequency (Hz)');
ylabel('|P1(f)|');
To embed this program on your website, copy the following code and paste it into your website's HTML: