Matrix to vector

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt

shm83
Posts: 35
Joined: Tue Sep 10, 2013 5:00 am

Matrix to vector

Postby shm83 » Tue Aug 12, 2014 5:53 am

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

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13585
Joined: Tue Sep 16, 2008 5:38 pm

Re: Matrix to vector

Postby EViews Gareth » Tue Aug 12, 2014 7:22 am

Use the @vech function on the transpose of the matrix.

shm83
Posts: 35
Joined: Tue Sep 10, 2013 5:00 am

Re: Matrix to vector

Postby shm83 » Mon Aug 18, 2014 11:15 pm

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. :)


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests