Path: news.mathworks.com!not-for-mail
From: "Nick Denman" <ngdenmanNOSPAM@gmail.REMOVETHIS.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: modified unique
Date: Wed, 24 Oct 2007 13:04:49 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 35
Message-ID: <ffnfth$phu$1@fred.mathworks.com>
References: <1193230486.076915.167300@z24g2000prh.googlegroups.com>
Reply-To: "Nick Denman" <ngdenmanNOSPAM@gmail.REMOVETHIS.com>
NNTP-Posting-Host: webapp-06-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1193231089 26174 172.30.248.36 (24 Oct 2007 13:04:49 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 24 Oct 2007 13:04:49 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 745609
Xref: news.mathworks.com comp.soft-sys.matlab:434395



Hi Gopla

 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.
> 

You may want to try histc.

> 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.
> 

One possible way

A = [ 1 2 3 3 4 5 5 5 6 6 7 8 9];
AA = unique(A);
n = histc(A,AA);
AA(n==1);

> With Regards
> Gopla
> 

Cheers, Nick