Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 "erlarge" a numpy-matrix to numpy-array
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.
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])
PhysChem likes this post
Thank you!

This is exactly, what I want.

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  AttributeError: module 'numpy' has no attribute 'array aapurdel 7 484 May-29-2019, 02:48 AM
Last Post: heiner55
  Array in numpy Truman 5 2,903 May-26-2019, 10:14 AM
Last Post: snippsat
  [split] Array in numpy aapurdel 1 92 May-25-2019, 08:05 PM
Last Post: buran
  [numpy]add a value to an array elmismo999 1 126 May-23-2019, 04:15 PM
Last Post: michalmonday
  comparing each rows of two matrix PhysChem 10 781 May-17-2019, 06:50 AM
Last Post: Gribouillis
  Inverse of singular matrix Divanova94 4 250 May-11-2019, 02:40 AM
Last Post: scidam
  matrix by vector mcgrim 8 217 May-02-2019, 10:39 AM
Last Post: ichabod801
  Extract of matrix subpart using a deep copy paul18fr 2 125 May-02-2019, 06:49 AM
Last Post: paul18fr
  Help in adding confusion matrix Aashish 5 371 Apr-15-2019, 11:45 PM
Last Post: scidam
  while creating a array using numpy.arrange, how to negate only the last 50 numbers? vicky53 1 180 Apr-06-2019, 11:52 AM
Last Post: scidam

Forum Jump:

Users browsing this thread: 1 Guest(s)