How to map a set of integer IDs to serial natural numbers?
Show older comments
Hello,
I'm trying to map a set of IDs which are integers to a list of serial numbers. So, for example, the IDs are as follows:
[12 13 20 12 5 12 13]
then the output should be
[2 3 4 2 1 2 3]
Thus, 5 has been mapped to 1 and 20 has been mapped to 4.
Is there a clever and efficient way to accomplish this? I believe the command 'unique' should help, but I'm not able to find a way to use it.
Accepted Answer
More Answers (0)
Categories
Find more on Variables in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!