Explanation

strmatch is not recommended. Use strncmp instead.


Suggested Action

To find possible partial matches for a character vector, use strncmp or validatestring, depending on your requirements. strncmp returns the numeric index of all array elements that begin with the specified character vector, whereas validatestring returns a single character vector that represents the best match to the specified character vector. To find an exact match for a character vector, use strcmp.

For instance, if your code currently contains lines such as these:

list = {'max', 'minimax', 'maximum', 'max'} 
x = strmatch('max',list)

MATLAB returns the numeric indices of the list array elements that begin with max:

x =

     1
     3
     4

Replace strmatch with one of the following:

If your input to strmatch is a character matrix, then first convert the matrix to a cell array using cellstr. Then, pass the output from cellstr to strncmp or validatestring. For example, if your code is currently this:

 x = strmatch('max', char('max','minimax', 'maximum', 'max'))

Replace it with this:

list = cellstr(char('max', 'minimax', 'maximum', 'max'))
x = strncmp('max', list, 3)

MATLAB returns:

x =

     1
     0
     1
     1