contains() does not recognize the second string as a valid
조회 수: 17 (최근 30일)
이전 댓글 표시
MathWorks Support Team
2018년 3월 29일
답변: MathWorks Support Team
2018년 3월 29일
I am trying to use the "contains" function on elements of a cell and I am receiving an error:
>> temp = {'one', 'two', 'three'}
>> for i=1:length(temp)
>> contains(temp{1:i}, 't');
>> end
Error using contains
Unrecognized parameter name 't'. Parameter name must be 'IgnoreCase'.
Error in example (line 3)
contains(temp{1:i}, 't');
채택된 답변
MathWorks Support Team
2018년 3월 29일
The reason you are receiving this error is because temp{1:i} is outputting two strings.
>> temp{1:i}
ans =
'one'
ans =
'two'
Then, the "contains" function sees those two strings as the first two inputs to the function. It compares the string 'one' to the string 'two'. It then thinks the third input to the "contains" function is 't', but the third input can only be 'IgnoreCase', which is why you are receiving this error.
Change:
>> temp{1:i}
To:
>> temp{i}
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Dates and Time에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!