I want to create a meshgrid and I only have one 2-dimensional array.
I want to create this:
a = np.array([1,2])
b = np.array([3,4])
mesh = np.array(np.meshgrid(a, b))
## mesh =
## array([[[1, 2],
## [1, 2]],
##
## [[3, 3],
## [4, 4]]])
but the input is one array containing a and b, like this:
ab = np.array([[1,2],[3,4]])
mesh = np.array(np.meshgrid(ab))
## mesh =
## array([[[1, 2],
## [1, 2]],
##
## [[3, 3],
## [4, 4]]])
Is their a way to archive that even with 3 or 4 arrays packed in one big one like this:
abcd = np.array([[1,2],[3,4],[5,6],[7,8]])