From: Bruno Luong on
"Namo Namo" <wynamo(a)yahoo.com> wrote in message <i1q828$sd0$1(a)fred.mathworks.com>...
> Thanks for the reply. Yes, the second output of unique is already what I want.
>
> I actually had a more general re-assignment problem to deal with, in which not just re-assign to the order stats. But now I find out I can just use table lookup or interp1. Say if I want to convert 3 1 4 to 1 2 3, and need to apply this conversion to a large matrix X, I can just do
>
> interp1([3 1 4], [1 2 3], X)
>
> and it replaces 3 1 4 in X to 1 2 3.

INTERP1 is slows (a hammer). The look up table is better coded simply by ... a look up table.

% Note: Use third output UNIQUE if values are not integer
table([3 1 4])= 1:3;
Y = table(X)

% or by ISMEMBER

[~, Y]=ismember(X,[3 1 4])

% Bruno