seach string in arraycell and find idx
조회 수: 3 (최근 30일)
이전 댓글 표시
C = {'A',31;
'B',5;
'C',3}
idx = find(ismember(C,{'A'}))
댓글 수: 0
채택된 답변
추가 답변 (1개)
Dyuman Joshi
2023년 9월 18일
When using ismember, if any of the input is a Cell array, it is expected that it will be a cell array of character vectors.
> which is what the error states
> which is mentioned in the documentation as well - Input Arguments for ismember()
But C is not a homogenueous cell array of character vectors, it has numeric data as well. So the above code does not work.
C = {'A',31;
'B',5;
'C',3}
%Comparing with cell array of character vector
idx = find(strcmp(C,{'A'}))
%Comparing with character
idx = find(strcmp(C,'A'))
%Comparing with string
idx = find(strcmp(C,"A"))
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Other Formats에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!