Generate numeric code based on string value

조회 수: 15 (최근 30일)
phlie
phlie 2016년 8월 16일
답변: Thorsten 2016년 8월 16일
In my cell array, I have one column which contains string values such as a_abc_ABC. How can I generate a new column/ variable which assigns a number to each a_abc_ABC combination? E.g., a_abc_ABC could be 1, a_def_ABC could be 2 etc.

채택된 답변

Thorsten
Thorsten 2016년 8월 16일
c = {'a_abc_ABC', 'a_def_ABC', 'b_def_ABC', 'a_abc_ABC', 'a_def_ABC'};
[~, ~, c_num] = unique(c);

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Types에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by