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.str bytes issue jrmusiov 0 18 2 hours ago
Last Post: jrmusiov
  numpy.where array search for string in just one coordinate adetheheat 1 153 Jan-09-2020, 07:09 PM
Last Post: paul18fr
  Corrupted numpy arrays when save to file. DreamingInsanity 2 256 Dec-14-2019, 12:12 PM
Last Post: DreamingInsanity
  Numpy saving and loading introduces zeros in the middle of every element DreamingInsanity 0 101 Dec-11-2019, 07:21 PM
Last Post: DreamingInsanity
  numpy.append() in Python ankushshah 1 139 Nov-08-2019, 06:18 AM
Last Post: ThomasL
  memory issue loading movie to numpy array djf123 1 126 Nov-07-2019, 06:19 AM
Last Post: ThomasL
  Numpy structured array Nitram 3 319 Sep-17-2019, 10:09 PM
Last Post: jefsummers
  Simple numpy reshape error wih contour3D AdeIsHere 0 219 Sep-17-2019, 12:01 PM
Last Post: AdeIsHere
  Numpy arrays and compatability with Fortran arrays merrittr 0 236 Sep-03-2019, 03:54 AM
Last Post: merrittr
  import numpy in sub-files paul18fr 1 270 Aug-06-2019, 12:38 PM
Last Post: chakrimakam

Forum Jump:


Users browsing this thread: 1 Guest(s)