seach string in arraycell and find idx
2 ビュー (過去 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!