필터 지우기
필터 지우기

give a id to same values in a cell

조회 수: 1 (최근 30일)
Elysi Cochin
Elysi Cochin 2016년 5월 30일
편집: Stephen23 2016년 5월 30일
i have a cell with values
{'aa', 'aa', 'ab' ,'ab', 'ab', 'ac', ac', 'ad'};
now i want to give a number to same words eg:
[1 1 2 2 2 3 3 4];
please can someone help me...

채택된 답변

Stephen23
Stephen23 2016년 5월 30일
편집: Stephen23 2016년 5월 30일
You can use unique:
>> C = {'aa', 'aa', 'ab' ,'ab', 'ab', 'ac', 'ac', 'ad'};
>> [~,~,idx] = unique(C)
idx =
1 1 2 2 2 3 3 4

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by