My question is more of a general question about how np.meshgrid is organized to understand it better. So I have a set of 3d points and for each point I have a scalar value associated with it. So for this function is shaped as n x 1, however now I want to reshape this function with the same values, to a np.meshgrid this means to make it to a 3D numpy array. However I don't understand how can I begin to do that this, since I don't know how it supposed to look like. Do you know how I can do this and the reasoning behind it?
Thank you I'm really new to np.meshgrids and I still can't comprehend it fully.
I will explain it in 2D (going to 3D if you understand it is quite easy).
Just imagine you have a section from the two dimensional plane. Lets say its a square with 5 in length and width. But the coordinates for x are in [10,15] and for y in [15,20], respectively.
Now you want to evaluate a function on this section (lets say with a resolution of 0.5). Numpys meshgrid now gives you two matrices in which the x and y coordinates for each "pixel" (0.5 x 0.5 area) are saved.
In some code this looks like:
our area is dived into 10x10 pixels and therefore we expect the shapes to be:
looking at
xx
:and
yy
:so to the the coordinates for the 4 pixel into x and 5 pixel into y direction you can just get:
If you want in 3D you have three cubes instead of two matrices that's basically it.
Now if you want to evaluate a function on this lets say:
you can just use
xx
andyy
like:and it looks like: