Find index of an arbitrary cell array that contains a string

조회 수: 20 (최근 30일)
Leo Simon
Leo Simon 2020년 6월 10일
답변: madhan ravi 2020년 6월 10일
In This thread, @Jan answers the question in the title for the case of cell arrays that consist only of character variables.
It doesn't work for more cell arrays that contain numbers and variables, e.g.,
dog = {1,'cat'}
Index = find(contains(dog,'cat'))
returns an error. Could somebody explain the solution for the case of general arrays? Thanks

채택된 답변

madhan ravi
madhan ravi 2020년 6월 10일
Index = find(strcmp(dog,'cat'))

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by