# 3D plot from Fourier coefficients in Matlab

I would like to construct a surface on a 2D mesh, given a set of Fourier coefficients for the original function $V(x,y)$.

Given some $\mathbb{K}\subset \mathbb{Z}^2$ I have a partial double sum of a Fourier series for $V(x,y)$, which could be some potential, for example

$V(x,y)=\frac{1}{\sqrt{x^2+y^2}}$

then

$f(x,y)=\sum_{(j,k)\in \mathbb{K}} v_{j,k} \exp(2 \pi i \cdot (jx+ky))$.

I am going to use Matlab for this to begin with so my question:

1. How can I generate a finite set of Fourier coefficients given $V$ in Matlab?

2. Once I have these coefficients what would the best method to plot them in 3D/contour plot?

• Wouldn't that just be F=fft2(V);surf(F) where V is evaluated on a 2d grid? – Christian Clason Jan 31 '16 at 15:10
• If you have the values of V evaluated on the 2d grid, then you do fft2(V), then will those values be the Fourier coefficients? If so this can be my means of getting some test data, but you will need to take the inverse ifft2( fft2(V)) to plot a surface right? – shilov Jan 31 '16 at 15:37
• That's what the (discrete) Fourier transform does: compute the Fourier coefficients from point values. I don't know what you mean by "surface" -- I interpreted this as plotting the Fourier coefficients as functions of $(k,j)$. If you have coefficients $v = (v_{jk})$ and want to plot point values $f(x,y)$, you'd use the inverse Fourier transform, f = ifft2(v); surf(f) (ifft2(fft2(V))=V by definition of the inverse transform). This assumes that $\mathbb{K}$ is rectangular and uniformly spaced; if $\mathbb{K}$ is arbitrary, you'd need to use the nonuniform Fourier transform (e.g., NUFFT). – Christian Clason Jan 31 '16 at 15:57