Demonstration of Fourier series in continuous time signal

Version 1.0.0 (273 KB) by SRIHARANI
The Fourier series is a powerful mathematical tool used to represent periodic functions as a sum of sinusoidal functions.
3 Downloads
Updated 24 Apr 2024

View License

Signal processing applications can demonstrate the Fourier series of continuous time signal in application such as audio signal processing.
Music and sound synthesis explore the application of Fourier series in music and sound synthesis.
Real world signal analysis apply Fourier signal such as biomedical signals (EEG,ECG)
% Parameters
T = 1; % Period of the signal
fs = 1000; % Sampling frequency
t = 0:1/fs:5*T; % Time vector
% Generate a continuous-time signal
x = sawtooth(2*pi*t/T); % Sawtooth wave with period T
% Compute the Fourier series coefficients
N = 20; % Number of harmonics
a0 = mean(x); % DC component
an = zeros(1, N); % Initialize array for cosine coefficients
bn = zeros(1, N); % Initialize array for sine coefficients
for n = 1:N
an(n) = 2/T * trapz(t, x.*cos(2*pi*n*t/T)); % Cosine coefficient
bn(n) = 2/T * trapz(t, x.*sin(2*pi*n*t/T)); % Sine coefficient
end
% Reconstruct the signal using the Fourier series
x_hat = a0/2;
for n = 1:N
x_hat = x_hat + an(n)*cos(2*pi*n*t/T) + bn(n)*sin(2*pi*n*t/T);
end
% Plot the original signal and reconstructed signal
figure;
subplot(2,1,1);
plot(t, x);
title('Original Signal');
xlabel('Time');
ylabel('Amplitude');
subplot(2,1,2);
plot(t, x_hat);
title('Reconstructed Signal using Fourier Series');
xlabel('Time');
ylabel('Amplitude');

Cite As

SRIHARANI (2024). Demonstration of Fourier series in continuous time signal (https://www.mathworks.com/matlabcentral/fileexchange/164326-demonstration-of-fourier-series-in-continuous-time-signal), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2024a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Acknowledgements

Inspired by: Fourier series of real signals

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.0.0