Filter löschen
Filter löschen

give a id to same values in a cell

1 Ansicht (letzte 30 Tage)
Elysi Cochin
Elysi Cochin am 30 Mai 2016
Bearbeitet: Stephen23 am 30 Mai 2016
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...

Akzeptierte Antwort

Stephen23
Stephen23 am 30 Mai 2016
Bearbeitet: Stephen23 am 30 Mai 2016
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

Weitere Antworten (0)

Kategorien

Mehr zu Multidimensional Arrays finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by