Need help initialising a 2D array

  • Thread starter Thread starter pamparana
  • Start date Start date
  • Tags Tags
    2d Array
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
1 reply · 2K views
pamparana
Messages
123
Reaction score
0
Hello everyone,

I have a newbie Matlab question. I need to set up a 2D array 'phi' whose gradient is an identity mapping in terms of the spatial coordinate.

So, basically I have a 2D image and what I want to do is set up phi at each pixel (x, y) as follows:

phi(x, y) = 0.5 * (x^2 + y^2), so that grad(phi(x, y)) = (x, y).

My question is how can I set this up in Matlab in an efficient way. So, given a 2D image, how can I set up this phi using the equation phi(x, y) = 0.5 * (x^2 + y^2).

Any help would be greatly appreciated.

Many thanks,

Luca
 
Physics news on Phys.org