How do convert array x to array z?
10 次查看(过去 30 天)
显示 更早的评论
Hi, How do convert array x to array z ?
x = [4 4 8 8 8 5 5 4 8 8 4]
Z = [1 1 2 2 2 3 3 1 2 2 1]
4 -> 1
8 -> 2
5 -> 3
0 个评论
采纳的回答
更多回答(1 个)
Andrei Bobrov
2018-8-28
编辑:Andrei Bobrov
2018-8-28
or just:
[~,~,z] = unique(x,'stable');
or more
[~,z] = ismember(x,[4 8 5]);
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!