From: us on
"Namo Namo" <wynamo(a)yahoo.com> wrote in message <i1ooqv$31l$1(a)fred.mathworks.com>...
> I need to re-assign the elements in a matrix to another set of values. The simplest, say, is
> to assign by order stats. For example, if I have
>
> a = [ 1 3 4 6 3 1 4 ];
>
> By order stats, I only have 4 unique elements 1 3 4 6. I would like to re-number the elements to 1 2 3 4. Currently I am using unique:
>
> [d, I, J] = unique( a(:) );
> new = 1:length(d);
> a2 = new(J);
>
> This is good enough, but not so intuitive? Any other suggestions?

hmm...
isn't J already what you're looking for(?)...

a=10*[1,2,3,1,2,3];
[au,ax,ax]=unique(a);
an=1:numel(au);
an=an(ax);
isequal(ax,an)
% ans = 1

us