Fourier series question, in regards to integration and plotting finite sums
4 次查看(过去 30 天)
显示 更早的评论
f(t) = 1 : 0 <t<pi/2 and 0: -pi/2 <t <0, f(t+pi) = f(t)
回答(1 个)
Sam Chak
2025-4-10
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Calculus 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

