How to calculate double Fourier coefficients A_kl and B_kl from W(x,y) when the W(x,y) was not defined in mathematical way?

9 views (last 30 days)
As the title, if I have a data x,y,z which is axial length, circumferential length and deviation, respectively. And I would like to use double Fourier series to approximate the random field W(x,y) which is
So it means that I can use the Fourier coefficients A_kl and B_kl to describe the deviation pattern W(x,y)
But the problem is that the W(x,y) is a random data and it was not defined in mathematical way. Then how can I calculate the A_kl and B_kl from unknow W(x,y)?
I tried to use curve fitting to fit the surface but it doesn't give me satisfying result. (Black dots are my xyz data)
Interpolation fitting gives a good agreement with my scatter but I cannot get the mathematical definition of the fitting curve.
So my problem is: How to get the Fourier coefficients from arbitrary W(x,y) which was not defined? If it must be defined as a function W(x,y), then which method should I use? Hope that someone could give me an idea, thank u so much.

Accepted Answer

Drishti
Drishti on 4 Mar 2025
To calculate the fourier coefficients from an arbitarary function ( W(x, y) ), it needs to be defined over a specified domain or can be approximated using the data points.
To approximate the function ( W(x, y) ) using a double Fourier series, we determine the coefficients ( A_{kl} ) and ( B_{kl} ) through integration.
You can refer to the below given code snippet for calculating the coefficients:
% Define the function W(x, y), taking example function
W = @(x, y) sin(x/10) .* cos(y/10);
% Initialize coefficients
Akl = zeros(n1+1, n2+1);
Bkl = zeros(n1+1, n2+1);
% Calculate coefficients Akl and Bkl
for k = 0:n1
for l = 0:n2
integrandA = @(x, y) W(x, y) .* cos(k*pi*x/L) .* cos(l*pi*y/R);
integrandB = @(x, y) W(x, y) .* cos(k*pi*x/L) .* sin(l*pi*y/R);
Akl(k+1, l+1) = (alpha/(2*pi*R*L)) * integral2(integrandA, 0, L, 0, 2*pi*R);
Bkl(k+1, l+1) = (alpha/(2*pi*R*L)) * integral2(integrandB, 0, L, 0, 2*pi*R);
end
end
% Define the approximation function
f_F = @(x, y) t * sum(sum(...
cos((0:n1)'*pi*x/L) .* (Akl .* cos((0:n2)*pi*y/(2*pi*R)) + Bkl .* sin((0:n2)*pi*y/(2*pi*R))) ...
));
I hope this helps in getting started.

More Answers (0)

Categories

Find more on Interpolation in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!