Fourier series question, in regards to integration and plotting finite sums
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
f(t) = 1 : 0 <t<pi/2 and 0: -pi/2 <t <0, f(t+pi) = f(t)
2 Commenti
Risposte (1)
Sam Chak
il 10 Apr 2025
Hi @Thomas
I also struggled with calculating the integrations (by hand) while learning Fourier series many years ago. A friend taught me this 'dirty and fast trick' to find the coefficients of the Fourier series using MATLAB. Please note that linear and constant functions, as well as discontinuities, cannot be perfectly expressed by the Fourier series in finite terms. The example below includes up to eight terms of both sines and cosines.
However, if you wish to calculate the Fourier integrals 'fair and square', please provide the formulas for the coefficients
,
,
, and the angular frequency ω.
%% Set heaviside(0) to 1, because OP didn't specify whether f(0) is 1 or 0.
sympref('HeavisideAtOrigin', 1);
%% the signal
t = linspace(-pi, pi, 3601);
f = heaviside(sin(2*t));
plot(t/pi, f, 'linewidth', 1.5), grid on, ylim([-0.5, 1.5])
xlabel('t/\pi'), ylabel('f(t)'), title('The signal, f(t)')
%% the fourier series
[fc, gof] = fit(t', f', "fourier8")
plot(fc, t, f), grid on, axis([-pi, pi, -0.5, 1.5])
xlabel('t'), ylabel('f(t)'), title('Eight-term Fourier Series Model')
0 Commenti
Vedere anche
Categorie
Scopri di più su Calculus in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

