How do you do a radial Fourier transform in MATLAB?
Show older comments
I have 'r' and a function 'f(r)' as vectors of numbers, with r ranging from 0.05 to 17.95. I want to calculate the radial Fourier transform:
which is the equation that I'm trying to calculate, except for some normalizing constants. After loading 'r' and 'fr', the latter being f(r), here's what I try so far:
Q = linspace(0.01,17.95,1000)';
R = linspace(0.01,17.95,1000)';
fR = @(R) interp1(r,fr,R,'spline');
integrand_fft = @(R,Q) (R.^2).*(fR(R)-1)./(Q.*R);
fQ_fft_v = -imag(fft((R.^2).*integrand_fft(R,Q)));
but the result appears symmetric and does not reach and asymptotic value that I expect, so I think that I did something wrong. How do I set up this code correctly?
Accepted Answer
More Answers (1)
5 Comments
David Goodmanson
on 8 May 2020
again, not knowing what your f(r) looks like makes it hard to comment.
David Goodmanson
on 9 May 2020
This function is very spead out and slow moving in the r window. Nothing wrong with that, but it does mean that in the q window, qFq will be scrunched up against the origin. Keeping array spacing delr the same and extending the r window out further, by a factor of 5 for example (consequently the number of points increases by a factor of 5) will improve the frequency resolution in q [see last paragraph]. In any case you will have to zoom in toward the origin in the q plot as you are doing.
It makes sense that there are oscillations in f(q) since the f(r) function does not get going until you are well away from the origin. That resembles a shift in f(r) which leads to an oscillatory phase factor in f(q).
the golden rule is just a necessary consequence of the fft. In terms of f and t, suppose you have a time array, N points with spacing delt. The time window is T = delt*N. With fourier transform by fft, an even number of oscillations have to occur in the time window. So f1*T = 1, f2*T = 2, f3*T = 3 etc. That means that (f_n+1 - f_n)*T = delf*T = 1. So delf = 1/(N*delt) and delf*delt = 1/N. Since w = 2*pi*f, then delw*delt = 2*pi/N. That's the basic situation with r and q.
Note that if delr*delq = 2*pi/N, then keeping delr the same and increasing the width of the r window by increasing N means that delq gets smaller. So there is Increased frequency resolution.
David Goodmanson
on 10 May 2020
The fft operates on functions with an array index. It doesn't know anything about what the distance between array points is, so to create an integral you have to supply that yourself.
The r and q arrays have zero at the center, but the fft wants zero as the first element. fftshift and ifftshift accomplish that.
Categories
Find more on Fourier Analysis and Filtering 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!








