フィルターのクリア

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 Center および File ExchangeMultidimensional Arrays についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by