Reputation: 356
I have a problem making a bigger matrix out of smaller matrixs.
Lets suppose i have the matrices:
1 2 3
A= 4 5 6
7 8 9
and
1 0 0
B= 0 1 0
0 0 1
The result i want to get is
1 2 3 1 0 0
C = 4 5 6 0 1 0
7 8 9 0 0 1
If I'm to do this in MATLab it would be as simple as doing C = [A B]
But I'm working with python at the momment.
How could one do that thing in python?
Btw, in python the matrices A and B would be made by my program and they would be ndarrays (at my problem, they are 15000x1626 arrays, or matrices, if needed to be).
Thanks alot for the help.
Upvotes: 1
Views: 1234
Reputation: 68692
try using np.hstack
:
C = np.hstack((A,B))
or np.concanenate
:
C = np.concatenate((A,B),axis=1)
Upvotes: 2