How to replace name with number

2 次查看(过去 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 CenterFile Exchange 中查找有关 Logical 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by