Path: news.mathworks.com!not-for-mail
From: "John D'Errico" <woodchips@rochester.rr.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: modified unique
Date: Wed, 24 Oct 2007 13:02:24 +0000 (UTC)
Organization: John D'Errico (1-3LEW5R)
Lines: 36
Message-ID: <ffnfp0$ngl$1@fred.mathworks.com>
References: <1193230486.076915.167300@z24g2000prh.googlegroups.com>
Reply-To: "John D'Errico" <woodchips@rochester.rr.com>
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 1193230944 24085 172.30.248.35 (24 Oct 2007 13:02:24 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 24 Oct 2007 13:02:24 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 869215
Xref: news.mathworks.com comp.soft-sys.matlab:434394



 gopla <gopalgajjar@gmail.com> wrote in message 
<1193230486.076915.167300@z24g2000prh.googlegroups.com>...
> Hi,
>      I have a array A = [ 1 2 3 3 4 5 5 5 6 6 7 8 9] and want output B
> = [1 2 4 7 8 9]
> 
> i.e. select only the unique numbers from the array and discard all
> numbers that get repeated in the original array.
> 
> I have tried with 'unique' and then a for loop which 'find' number of
> occurrence of a element of the output of unique in the original array.
> I want to simplify this and try to remove the for loop.


A = [ 1 2 3 3 4 5 5 5 6 6 7 8 9];

[B,count] = consolidator(A);
B(count>1) = [];

B =
     1
     2
     4
     7
     8
     9

Find consolidator on the file exchange. (Beware
the wrapped URL. Copy both lines into your
browser)

http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?
objectId=8354&objectType=file

HTH,
John