Need help initialising a 2D array

  • Thread starter Thread starter pamparana
  • Start date Start date
  • Tags Tags
    2d Array
Click For Summary
SUMMARY

The discussion focuses on initializing a 2D array 'phi' in MATLAB, where phi is defined by the equation phi(x, y) = 0.5 * (x^2 + y^2). This setup ensures that the gradient grad(phi(x, y)) equals (x, y), effectively creating an identity mapping in spatial coordinates. The user, Luca, seeks efficient methods to implement this in MATLAB, and the meshgrid function is recommended for generating the necessary x and y vectors for the 2D array.

PREREQUISITES
  • Familiarity with MATLAB programming
  • Understanding of 2D arrays and matrix operations
  • Knowledge of gradient calculations in multivariable functions
  • Experience with the meshgrid function in MATLAB
NEXT STEPS
  • Explore MATLAB's meshgrid function for generating coordinate grids
  • Learn about gradient functions in MATLAB, specifically the gradient() function
  • Investigate efficient array initialization techniques in MATLAB
  • Study visualizing 3D plots in MATLAB using the surf() function
USEFUL FOR

MATLAB users, data scientists, and engineers looking to perform operations on 2D arrays and understand gradient mappings in spatial coordinates.

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
Last edited by a moderator:

Similar threads

  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 26 ·
Replies
26
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 1 ·
Replies
1
Views
1K