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

回答 (1 件)

Thorsten
Thorsten 2016 年 10 月 6 日

0 投票

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

3 件のコメント

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

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeCharacters and Strings についてさらに検索

質問済み:

2016 年 10 月 6 日

コメント済み:

2016 年 10 月 6 日

Community Treasure Hunt

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

Start Hunting!

Translated by