Using the C++ Math Library    

Using a Logical Matrix As a One-Dimensional Index

When you use a logical matrix as an index, the result is a column vector. For example, you can create the logical index matrix B:

by calling mlfLogical().

Then A(B) equals:

Notice that B has ones at the corners and in the center, and that the result is a column vector of the corner and center elements of A.

If the logical index is not the same size as the subscripted array, the logical index is treated like a vector. For example, if B = [1 0; 0 1] then A(B) equals

since B has a zero at positions 2 and 3, and a 1 at positions 1 and 4. Logical indices behave just like regular indices in this regard.


 Overview Using Two Logical Vectors as Indices