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!