Using the C++ Math Library    

Using a Scalar and a Logical Vector

Let matrix X be a 4-by-4 magic square.

Let B be a logical matrix that indicates which elements in row 2 of matrix X are greater than 9. B is the result of the greater than (>) operation

and contains the vector

Use B as a logical index that selects those elements from matrix X.

selects these elements:


 Using One colon() Index and One Logical Vector as Indices Extending Logical Indexing to N Dimensions