From: Namo Namo on
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?