Explanation

The code uses findstr to find one character vector within another, longer character vector. MathWorks recommends you use strfind instead. The findstr function can be confusing because the order of the input arguments is not important. The strfind function is more predictable because it always looks for the second input within the first input.


Suggested Action

Use strfind instead of findstr.

For example, if you define a character vector, s, as follows:

s = 'Here is a long character vector.';

To find the starting indices of the character vector, long, within s, use this code

strfind(s,'long')

rather than either of the following:

findstr(s,'long')
findstr('long',s)