A newbie question and possible duplicate: How can one compose a matrix in numpy using arrays or 1d matrices? In matlab, I would use following syntax for the matrix consisting of three arrays treated as rows:
A=[1; 1; 1];
B=[2; 2; 2];
C=[3; 3; 3];
D=[A B C]
The result is:
D =
1 2 3
1 2 3
1 2 3
Thank you
You should do
import numpy as np
A = np.array([1, 1, 1])
B = np.array([2, 2, 2])
C = np.array([3, 3, 3])
D = np.vstack((A, B, C))
See NumPy for MATLAB users (official link seems to be down)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.