How to replace name with number

Hello guys !!
I've a question for you. I got a cell array like that x = {'white' 'red' 'blue' 'yellow'}. My intention is to replace my cell array with a number vector, so that white become 1, red become 2.. and so on. How can i do that?
ty

Antworten (1)

Thorsten
Thorsten am 6 Okt. 2016

0 Stimmen

[~, ~, xnum] = unique(x, 'stable')

3 Kommentare

Light.16
Light.16 am 6 Okt. 2016
sorry sir..
but i did't understand :(
Light.16
Light.16 am 6 Okt. 2016
which tipe of function is that? IT WORKS!!! :D but how did you do that =???
In matlab type
doc unique
to read its documentation

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Entering Commands finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 6 Okt. 2016

Kommentiert:

am 6 Okt. 2016

Community Treasure Hunt

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

Start Hunting!

Translated by