필터 지우기
필터 지우기

duplicating strings in a cell array

조회 수: 1 (최근 30일)
AT_HYZ
AT_HYZ 2023년 12월 2일
댓글: madhan ravi 2023년 12월 2일
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일
[~, 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개)

카테고리

Help CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by