Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Matlab Fourier transform of a 2D shape

  1. Mar 21, 2016 #1
    I have a function of 2 variables [f(x,y)] where if there was an ellipse in the x-y plane, all values of the function are 1 inside the ellipse and 0 outside. I can plot this function as a surface in 3d where it looks like an elevated ellipse hovering over an elliptical hole in a sheet.

    My problem is this, the Fourier transform of this shape [F(x,y)] can be found analytically by using a new coordinate (e.g. chi = sqrt( ax ^2 + by ^2)), resulting in a bessel function divided by chi [ proportional to J(chi)/chi].

    I would like to find F numerically in matlab but I have no idea how to do this. Previously I could do FT's of single variable functions ( for instance a boxcar function) by creating a vector x and k and then doing something like this:

    for length k
    F = 0
    for length x
    F = F + f*exp(-i k x)
    end
    end

    For two variables however, I created a meshgrid for x and y and defined f using that. Should I do something else?
     
  2. jcsd
  3. Mar 21, 2016 #2

    BvU

    User Avatar
    Science Advisor
    Homework Helper
    Gold Member

  4. Mar 21, 2016 #3
    Indeed. But my question is how to implement this into matlab. I have a vector x, a vector y and a function f formed from the meshgrid[x,y]. how do I do the sums (without using stuff like fft)?
     
  5. Mar 21, 2016 #4

    BvU

    User Avatar
    Science Advisor
    Homework Helper
    Gold Member

    ehm, perhaps you can reduce your 2D to 1D by compressing your ellipse into a circle (x -> x/a, y-> y/b) . And make use of these Bessel functions that pop up in e.g. fraunhofer diffraction from a circular aperture (matlab example -- but I concede that it isn't doing the Fourier integrals).

    But what's wrong with the integrals in post #2 link ?
     
  6. Mar 22, 2016 #5

    DrClaude

    User Avatar

    Staff: Mentor

    As I told you in the other thread (please do not open more than one thread for the same problem), you need to do a series of FTs. Just as you make a FT f(j) → F(i), you will have to do f(j,k) → F(i,k) for each value of k. You then repeat the same procedure on the first index: F(k,j) → FF(k,i).

    If your goal is simply to have the FT of f(x,y), you should be doing an FFT, not a FT, and I don't see why you don't simply use the built-in Matlab function fft2:
    Code (Matlab M):
    F = fft2(f)
     
  7. Mar 30, 2016 #6
    i apologise sir but you simply don't understand my question. hence the new thread haha
     
  8. Mar 30, 2016 #7

    DrClaude

    User Avatar

    Staff: Mentor

    Then try to clarify your question in thread.

    From all that you have posted, it appears that you want to do a 2D Fourier transform. I explained how to do it manually in the other thread, thinking that it was part of the exercise for you to do it "from scratch," while here I suggested using FFTs, as it seems you are only interested in the end result.

    If this is not what you are after, then please respond with a clearer description of what you are after.
     
  9. Mar 30, 2016 #8
    once again haha, i do apologise. Clarity is indeed the issue. I'm not doing an exercise, I'm modelling strain in quantum dots in FORTRAN, and had to quickly run a matlab program at the time and couldn't (still can't) for the life of me figure out how to write F(i,j) in matlab, my programs wouldn't run with such obvious syntax.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted



Similar Discussions: Fourier transform of a 2D shape
Loading...