duplicating strings in a cell array

I have a cell array like this:
name = {'aa', 'bb', 'bb','cc','cc','ee','ff','ff','ff'};
I would like to get the indices which are duplicated. Idx = 2,4,7.
I use strcmp and it didn't work.

 採用された回答

madhan ravi
madhan ravi 2023 年 12 月 2 日
編集済み: madhan ravi 2023 年 12 月 2 日

0 投票

[~, b, c] = unique(name);
idx = b(sum(b(c) == unique(b(c)).') > 1)

1 件のコメント

madhan ravi
madhan ravi 2023 年 12 月 2 日
[~, b, c] = unique(name);
idx = b(accumarray(c, 1) > 1)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeCharacters and Strings についてさらに検索

タグ

質問済み:

2023 年 12 月 2 日

コメント済み:

2023 年 12 月 2 日

Community Treasure Hunt

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

Start Hunting!

Translated by