Page 1 of 1

Matrix to vector

Posted: Tue Aug 12, 2014 5:53 am
by shm83
Good afternoon.

I wonder if there is a way (command) to put all the elements of a matrix (row by row) into a vector without using a loop.

Example:
Matrix A = [2 3
4 5]
Vector B = [2 3 4 5]

Thanks in advance

Re: Matrix to vector

Posted: Tue Aug 12, 2014 7:22 am
by EViews Gareth
Use the @vech function on the transpose of the matrix.

Re: Matrix to vector

Posted: Mon Aug 18, 2014 11:15 pm
by shm83
thank you Gareth.
I used @vec because I needed the complete data. @vech is only for the upper triangle of a squared matrix, but I could have not reached to that without your help. :)