[Matrix-SIG] whats the best way to combine 1D arrays into 2D arrays?

eric jones ej@ee.duke.edu
Thu, 8 Oct 1998 05:00:58 -0400


Hello,

I'd like to take two 1D arrays and combine them as the rows of a 2D array.
For example, in Matlab, the following works:

x=1:3;
y=1:3;
z=[x;y]

so that
z= [[1,2,3]
      [1,2,3]]

The way I've done this in NumPy is:

x = arange(1,4)
y = arange(1,4)
z = concatenate( (reshape(x,[1,-1]),reshape(y,[1,-1]) ) )

Is there a more compact way of doing this?

thanks,
eric