T
T
Timebird2016-05-23 00:04:54
Python
Timebird, 2016-05-23 00:04:54

How to extract an array from a matrix?

Hello!
There is a 2x1 matrix. You need to push the elements (there are 80 of them) of the second row of this matrix into an array using numpy. I tried this myself, it didn't work:

newlist = []
for elem in np.matrix[1][0]:
    newlist.append(elem)
newarray = np.array(newlist)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
ADRian, 2016-05-23
@ADR

import numpy as np

matrix = np.matrix()
new_array = matrix[1][0]        # ссылка
new_array = matrix[1][0][:]     # копия
new_array = matrix[1][0].copy() # копия

I do not understand the question. How is it that 2x1 gives you 80.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question