ilovecp3 - 1 year ago 225

Python Question

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]? Thank you so much

Recommended for you: Get network issues from **WhatsUp Gold**. **Not end users.**

Answer Source

Use `numpy.concatenate`

:

```
>>> import numpy as np
>>> np.concatenate((A, B))
matrix([[ 1., 2.],
[ 3., 4.],
[ 5., 6.]])
```

Recommended from our users: **Dynamic Network Monitoring from WhatsUp Gold from IPSwitch**. ** Free Download**