Generate numeric code based on string value

21 ビュー (過去 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 Center および File ExchangeData Types についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by