new to Python, struggling in numpy, hope someone can help me, thank you!
from numpy import *
A = matrix('1.0 2.0; 3.0 4.0')
B = matrix('5.0 6.0')
C = matrix('1.0 2.0; 3.0 4.0; 5.0 6.0')
print "A=",A
print "B=",B
print "C=",C
results:
A= [[ 1. 2.]
[ 3. 4.]]
B= [[ 5. 6.]]
C= [[ 1. 2.]
[ 3. 4.]
[ 5. 6.]]
Question: how to use A and B to generate C, like in matlab C=[A;B]?
解决方案>>> import numpy as np
>>> np.concatenate((A, B))
matrix([[ 1., 2.],
[ 3., 4.],
[ 5., 6.]])
python 合并矩阵 python将两个矩阵合并
转载文章标签 python 合并矩阵 python如何对两个矩阵进行拼接 Python 解决方案 文章分类 Python 后端开发