Find index of an arbitrary cell array that contains a string

18 次查看(过去 30 天)
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