Using the C++ Math Library    

Selecting the Entire Matrix As a Column Vector

Use the colon() index to select all the elements in a matrix. The result is a column vector. For example, A(colon()) is:

The colon() index means ``all.'' Think of it as a context-sensitive function. It expands to a vector array containing all the indices of the dimension in which it is used (its context). In the context of an M-by-N matrix A, A(colon()) is equivalent to A(transpose(ramp(1,M*N))).


 Selecting a Matrix Using N-Dimensional Subscripts