Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 "erlarge" a numpy-matrix to numpy-array
#1
Hi all!

Is there a way to concatenate/append/"gluetogether" two (n*m-shaped) matrix into a single (n*m*2-shaped) array (with 3 axle), and not into an other (2n*m-shaped) or (n*2m-shaped) matrix?

I found a couple of websites about putting matrixes together, but these sites were about how to do it row~ or column~wise.
Quote
#2
So, you have two matrices of shape nxm and want to concatenate them by third axis and get one matrix of shape nxmx2.
Thats easy:
import numpy as np
A = np.random.rand(10, 20)
B = np.random.rand(10, 20)
C = np.dstack([A, B])
print(C.shape)
PhysChem likes this post
Quote
#3
Thank you!

This is exactly, what I want.
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  numpy.append() in Python ankushshah 1 66 Nov-08-2019, 06:18 AM
Last Post: ThomasL
  memory issue loading movie to numpy array djf123 1 43 Nov-07-2019, 06:19 AM
Last Post: ThomasL
  Numpy structured array Nitram 3 218 Sep-17-2019, 10:09 PM
Last Post: jefsummers
  Simple numpy reshape error wih contour3D AdeIsHere 0 137 Sep-17-2019, 12:01 PM
Last Post: AdeIsHere
  Numpy arrays and compatability with Fortran arrays merrittr 0 171 Sep-03-2019, 03:54 AM
Last Post: merrittr
  import numpy in sub-files paul18fr 1 211 Aug-06-2019, 12:38 PM
Last Post: chakrimakam
  Converting set of tuples to set of 2D numpy arrays ThemePark 0 234 Aug-04-2019, 05:07 PM
Last Post: ThemePark
  Trying to replace for loops with numpy vspoloni 8 798 Aug-04-2019, 07:09 AM
Last Post: paul18fr
  Add column to numpy matrix Gigux 1 266 Aug-02-2019, 12:05 AM
Last Post: scidam
  Python/C API Matrix to Numpy jibarra 0 174 Jul-29-2019, 03:25 PM
Last Post: jibarra

Forum Jump:


Users browsing this thread: 1 Guest(s)