time | Calls | line |
---|
| | 1 | function tf = partialMatchString(str, options, N)
|
| | 2 | % PARTIALMATCHSTRING Partial matching for string options.
|
| | 3 |
|
| | 4 | % Copyright 2017 The MathWorks, Inc.
|
| | 5 |
|
< 0.001 | 8 | 6 | if nargin < 3
|
< 0.001 | 8 | 7 | N = 1;
|
< 0.001 | 8 | 8 | end
|
| | 9 | % Possible options to match should be string/char/cellstr
|
< 0.001 | 8 | 10 | assert(isstring(options) || ischar(options) || iscellstr(options))
|
< 0.001 | 8 | 11 | if ~isstring(options)
|
| | 12 | options = string(options);
|
< 0.001 | 8 | 13 | end
|
| | 14 | % String to match must be scalar text
|
< 0.001 | 8 | 15 | if ~((ischar(str) && isrow(str)) || (isstring(str) && isscalar(str)))
|
| | 16 | tf = false(size(options));
|
< 0.001 | 8 | 17 | else
|
< 0.001 | 8 | 18 | tf = strncmpi(str, options, max(N, strlength(str)));
|
| | 19 | % No duplicate matches
|
< 0.001 | 8 | 20 | tf = tf & (nnz(tf) == 1);
|
< 0.001 | 8 | 21 | end
|
< 0.001 | 8 | 22 | end
|
Other subfunctions in this file are not included in this listing.