1

I want to create a matrix from 3 vectors:

import numpy as np v1 = np.array([10, 0]) v2 = np.array([120, 9]) v3 = np.array([100, 7]) M = np.concatenate((v1, v2, v3)) print(M) 

Results:

[10 0 120 9 100 7] 

Desired results:

10 120 100 0 9 7 

How to change the code in order to get the desired results ?

1
  • np.array((v1, v2, v3)).T Commented Jun 29, 2021 at 15:33

2 Answers 2

2

You can use np.stack with axis=1:

np.stack((v1, v2, v3), axis=1) 

Output:

array([[ 10, 120, 100], [ 0, 9, 7]]) 
Sign up to request clarification or add additional context in comments.

Comments

2
import numpy as np v1 = np.array([10, 0]) v2 = np.array([120, 9]) v3 = np.array([100, 7]) M = np.stack(v1, v2, v3), axis=1) print(M) 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.