How do I get MATLAB to automatically create a vector of unique values based on a known vector of values?
Show older comments
Let's say I have a vector of known values:
A = [10;20;30;100;200;10;20;30;40;50];
I'm looking for a way to get MATLAB to automatically create vector B of unique values, based on A.
So for the 7 unique values in A, B = [1;2;3;4;5;6;7]
Is there a way to make this happen?
Accepted Answer
More Answers (1)
Walter Roberson
on 17 Oct 2013
B = 1 : length(unique(A));
Categories
Find more on Startup and Shutdown in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!