| 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, if the logical index matrix B equals
1 0 1 0 1 0 1 0 1
mlfAssign(&X, mlfIndexRef(A, "(?)", B));
1 3 5 7 9
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.
Note that you can create B by calling mlfAssign(&B, mlfLogical(matrix)) where matrix stores a matrix of 1's and 0's.
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 = logical([1 0; 0 1]), then
mlfAssign(&X, mlfIndexRef(A, "(?)", B));
1 4
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 | ![]() |