dadadude
asked on
convert matrix to vector python
hello i want to know how can we convert a matrix to a vector in python?
in matlab if i have a matrix a = [[1 2 3];[4,5,6];[7,8,9]]
if i use a(:)
i will get :1
2
.
.
9
it's not working in python!!!
in matlab if i have a matrix a = [[1 2 3];[4,5,6];[7,8,9]]
if i use a(:)
i will get :1
2
.
.
9
it's not working in python!!!
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Do
b = a.flatten(1)
b = a.flatten(1)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
your example worked but I was wondering if i can do that with numpy.
because later i have to calculate a - 1.
and it's not working with that method.