Using the C++ Math Library | ![]() ![]() |
Selecting a Matrix
Use a matrix index to select a matrix. A matrix index works just like a vector index, except the result is a matrix rather than a vector. For example, let B
be the index matrix:
1 2 3 2
1 2 3 2
Note that the example matrix A
was chosen so that A(X) = X
for all types of one-dimensional indexing. This is not generally the case. For example, if A
were changed to A = magic(3)
,
8 1 6 3 5 7 4 9 2
8 3 4 3
Note
In both cases, size(A(B)) is equal to size(B) . This is a fundamental property of one-dimensional indexing. |
![]() | Selecting a Vector | Selecting the Entire Matrix As a Column Vector | ![]() |