Path: news.mathworks.com!not-for-mail
From: "Bruno Luong" <b.luong@fogale.findmycountry>
Newsgroups: comp.soft-sys.matlab
Subject: reassigning values of elements in matrix
Date: Fri, 16 Jul 2010 06:48:07 +0000 (UTC)
Organization: FOGALE nanotech
Lines: 16
Message-ID: <i1ovb7$hqb$1@fred.mathworks.com>
References: <i1ooqv$31l$1@fred.mathworks.com>
Reply-To: "Bruno Luong" <b.luong@fogale.findmycountry>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1279262887 18251 172.30.248.35 (16 Jul 2010 06:48:07 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 16 Jul 2010 06:48:07 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 390839
Xref: news.mathworks.com comp.soft-sys.matlab:653611

"Namo Namo" <wynamo@yahoo.com> wrote in message <i1ooqv$31l$1@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);
>  

[d, I, a2] = unique( a)

Bruno