重新索引向量中的某些值 [英] Reindexing some values in a vector

查看:84
本文介绍了重新索引向量中的某些值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个向量,大小像40000,值类似

I have this vector of size like 40000 with values like

12312345
4564
122356
3455
34566

此向量中只有大约200个唯一值.所以我想用1:200的数字代替这些大值

There are like only 200 unique values in this vector. So I want to replace these big values by numbers from 1:200

这样,最小的矢量值将被1替换,下一个最小的2将被替换,依此类推,直到200.

such that the smallest vector value will be replaced by 1, the next smallest by 2 and so on up to 200.

我该如何在matlab中做到这一点?

How can I do it in matlab?

推荐答案

unique的第三个输出将为您做到这一点!

The third output of unique will do that for you!

[~,~,NewVector]=unique(Vector)

这篇关于重新索引向量中的某些值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆