How to replace name with number

3 ビュー (過去 30 日間)
Light.16
Light.16 2016 年 10 月 6 日
コメント済み: Guillaume 2016 年 10 月 6 日
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 日
[~, ~, xnum] = unique(x, 'stable')
  3 件のコメント
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

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

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by