Simple real Fourier series approximation

バージョン 1.1 (3.37 KB) 作成者: Matt Tearle
Computes coefficients for the real Fourier series approximation to a data set.

ダウンロード 6K 件

更新 2020/3/3


Includes two functions: Fseries.m and Fseriesval.m
[a,b] = Fseries(X,Y,n) fits an nth-order Fourier expansion of the form
y = a_0/2 + Sum_k[ a_k cos(kx) + b_k sin(kx) ]
to the data in the vectors X & Y, using a least-squares fit.

Y = Fseriesval(a,b,X) evaluates the Fourier series defined by the coefficients a and b at the values in the vector X.

Extra arguments allow for rescaling of X data and sin-only or cosine-only expansions.

% Generate data
x = linspace(0,2,41)';
y = mod(2*x,1);
% Use FSERIES to fit
[a,b,yfit] = Fseries(x,y,10);
% Evaluate on finer grid
xfine = linspace(0,2)';
yfine = Fseriesval(a,b,xfine);
% Visualize results

This generates the attached image of a 10-term Fourier series approximation of a sawtooth wave.


Matt Tearle (2022). Simple real Fourier series approximation (, MATLAB Central File Exchange. 取得済み .

MATLAB リリースの互換性
作成: R2010b
Windows macOS Linux
タグ タグの追加

ヒントを与えたファイル: Spectral Curvefitting of Dielectric Constants

Community Treasure Hunt

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

Start Hunting!