Path: news.mathworks.com!not-for-mail
From: "Lee Newman" <newman.lee.nospam@comcast.net>
Newsgroups: comp.soft-sys.matlab
Subject: Re: modified unique
Date: Wed, 24 Oct 2007 13:05:45 +0000 (UTC)
Organization: University of Michigan
Lines: 34
Message-ID: <ffnfv9$qbq$1@fred.mathworks.com>
References: <1193230486.076915.167300@z24g2000prh.googlegroups.com>
Reply-To: "Lee Newman" <newman.lee.nospam@comcast.net>
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 1193231145 27002 172.30.248.36 (24 Oct 2007 13:05:45 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 24 Oct 2007 13:05:45 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 25887
Xref: news.mathworks.com comp.soft-sys.matlab:434396



 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.
> 
> With Regards
> Gopla
> 

Here's one approach that uses the tabulate function (see
help in statistics toolbox):

A = [ 1 2 3 3 4 5 5 5 6 6 7 8 9];
x=tabulate(A);
result=x(x(:,2)==1)'

I suspect there is lower-level/more concise function that
returns frequency counts that might be better than
tabulate(), but this works.