Path: news.mathworks.com!not-for-mail
From: "Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid>
Newsgroups: comp.soft-sys.matlab
Subject: Re: ABout 'unique' command
Date: Tue, 20 Nov 2007 03:47:55 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 24
Message-ID: <fhtldb$7q$1@fred.mathworks.com>
References: <fhtc36$lhk$1@fred.mathworks.com>
Reply-To: "Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1195530475 250 172.30.248.35 (20 Nov 2007 03:47:55 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 20 Nov 2007 03:47:55 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: news.mathworks.com comp.soft-sys.matlab:438460


"Chandra Varanasi" <chandravaranasi@yahoo.com> wrote in message 
<fhtc36$lhk$1@fred.mathworks.com>...
> 'unique' command outputs the final occurrence of a 
> repeating element. Is there a way to make it output the 
> first occurence instead?
> 
> Thanks
> 
> Example:  A = [6 7 6 8 11 3 5 11];
> 
> [B, IA, IB] = unique(A) gives
> 
> B = [3 5 6 7 8 11]
> IA = [6 7 3 2 4 8]
> IB = [something]
> 
> I would like IA to display [6 7 1 2 4 5] instead
---------
Use the "occurence" option:

 [B, IA, IB] = unique(A,'first');

Roger Stafford