Text comparisons no longer work with arrays in 2022a

조회 수: 5 (최근 30일)
Levi Blake
Levi Blake 2022년 6월 28일
편집: Matt J 2022년 7월 4일
I currently work with 2018a, but I've been trying to adapt some of my programs to 2022a. I'm noticing that there's been changes to functions that compare strings. Previously, I could use cell arrays as inputs to ismember(), contains(), strfind(), etc. so long as I unpacked the string arrays by including curly brackets. Now that no longer works, despite ismember() and strfind()'s purposes is to find strings within arrays. I've even tried converting the cell arrays to string arrays, but string() is having the same problems.
  댓글 수: 1
Matt J
Matt J 2022년 7월 4일
Bettina's comment moved here:
I have the same problem with the contains function in version R2022a. I just tried it in version 2019a, there it still works, but in the new version, an error message 'first argument must be text' occurs. What changed in the contains function for the new version?

댓글을 달려면 로그인하십시오.

답변 (1개)

Matt J
Matt J 2022년 6월 28일
편집: Matt J 2022년 7월 4일
There's been no change. cell arrays containing character vectors still work:
contains({'dog','fish','cat'},'cat')
ans = 1×3 logical array
0 0 1
What does not work are cell arrays containing strings,
contains({"dog","fish","cat"},'cat')
Error using contains
First argument must be text.

카테고리

Help CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by