IFFT2 as a Symbolic Function

11 vues (au cours des 30 derniers jours)
John Shackleton
John Shackleton le 10 Août 2020
I have a 2D matrix which I would like to take an explicit derivative with, so it may be helpful to have a functional form of the matrix. I thought performing a 2D FFT and then expressing the matrix in terms of the Fourier basis would be a good idea, but I'm having some difficulties. I'd like that if given parameters of an x, y meshgrid and the matrix f (which is a function of x and y) over the meshgrid, the function would create a function f2 such that f2(x(ii, jj), y(ii, jj)) = f(ii, jj).
xc = -10;
yc = -10;
d = -0.1;
[x, y] = meshgrid(xc:d:10, yc:d:10);
f = sin(x + y);
m = size(f, 1);
n = size(f, 2);
coefs = fft2(f);
omega_x = exp((2*pi.*1i./n).*(0:(n-1)));
omega_y = exp((2*pi.*1i./n).*(0:(m-1)));
omega_y = omega_y';
func = @(x, y) (1/m).*(1/n).*sum( ...
sum( ...
(omega_x.^((x-xc)./d).* ...
(omega_y.^((y-yc)./d))) ...
.*coefs ...
) ...
);
f2 = zeros(size(f));
for ii = 1:size(f, 1)
for jj = 1:size(f, 2)
f2(ii, jj) = func(x(ii, jj), y(ii, jj));
end
end
And we should have matrices f2 and f be similar.
Thanks for your help!

Réponses (0)

Catégories

En savoir plus sur MATLAB dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by