Language Reference

COLVEC Function

COLVEC (matrix) ;

This function is supported by the IML procedure and the iml action.

The COLVEC function is part of the IMLMLIB library. The COLVEC function converts a matrix into a column vector. If matrix is any n times m matrix, the COLVEC function returns an n m times 1 vector that contains the elements of matrix in row-major order. The first m elements in the vector correspond to the first row of the input matrix, the next m elements correspond to the second row, and so on, as shown in the following example.

x = {1 2 3,
     4 5 6};
y = colvec(x);
print y;

Figure 75: A Column Vector

y
1
2
3
4
5
6


See the ROWVEC function for converting a matrix into a row vector.

Last updated: July 20, 2026