Why does STRMATCH in MATLAB cause an error for a cell array containing a numeric value?
古いコメントを表示
Why does STRMATCH in MATLAB cause an error for a cell array containing a numeric value?
According to the help for STRMATCH:
I = STRMATCH(STR,STRS) looks through the rows of the character array or cell array of strings
STRS to find strings that begin with string STR, returning the matching row indices.
STRMATCH is fastest when STRS is a character array.
However, as the following example illustrates, STR can be a numeric value, and STRMATCH will not return an error.
str = 9;
strs = strvcat('This is a string array','with two rows');
ind = strmatch(str,strs);
The variable 'ind' will be empty. However, if I try to use STRMATCH with a cell array containing a double, I receive an error as in this next example:
str ={9};
strs = strvcat('This is a cell array of strings','with two rows');
ind = strmatch(str,strs);
??? Error using ==> cell/strmatch
Requires character array or cell array of strings as inputs.
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Characters and Strings についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!