[SciPy-user] Create n-dim array from axis
Mon Mar 23 09:20:16 CDT 2009
On Mon, Mar 23, 2009 at 10:07 AM, Paul Hilscher
>> try mx, my = numpy.meshgrid(x, y)
>> [zip(a,b) for (a,b) in zip(mx, my)]HTH,
> Thanks a lot David, this works perfectly fine for 2-dimensions.
> Is there any possibility to extend it to 3-dimensions with axis z, or
> even to 4-dimensions giving axis w ?
> Thanks again,
I would also like to know what an efficient way is to do this. For
arbitrary dimension, I never found anything except for a brute force
loop or recursive function.
For 2d you can convert the meshgrid directly to an ndarray
(2, 3, 3)
More information about the SciPy-user