Explanation

MATLAB enables you to use logical arrays for indexing elements in both arrays and cell arrays. This code calls find to create an array of indices from a logical vector, when you can probably use the logical vector directly instead. Using logical indexing directly is usually faster because it avoids the work find does when it creates a vector of indices.

Code Analyzer also reports this message when the subscript is an array of indices resulting from a call to find and the indicated subscript is the only use of this array of indices.


Suggested Action

To speed up and simplify the program, replace the call to find with logical array indexing. If the logical array is not a vector, the shape of the output could change when you remove (or use Code Analyzer automatic fix feature to remove) the find call. To retain the same output shape, you might need to replace find(L) by L(:) or L(:)'. Even with these changes, it is faster than calling find.

If the argument to find is not a logical array, suppress this message, as described in Adjust Code Analyzer Message Indicators and Messages.