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 two of matrix X are greater than 9. B is the result of the greater than (>) operation

and contains the vector

In MATLAB, B = (X(2,:) > 9) performs the same operation.

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