Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Count occurences by row
Date: Fri, 16 Jul 2010 21:05:09 +0000 (UTC)
Organization: Universit&#228;tsSpital Z&#252;rich
Lines: 25
Message-ID: <i1qhi5$2jl$1@fred.mathworks.com>
References: <i1q7ng$78g$1@fred.mathworks.com> <i1q9c0$li7$1@fred.mathworks.com> <i1qb9c$oo4$1@fred.mathworks.com> <i1qcj8$idl$1@fred.mathworks.com> <i1qdig$l7g$1@fred.mathworks.com> <i1qe3f$ouh$1@fred.mathworks.com>
Reply-To: <HIDDEN>
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 1279314309 2677 172.30.248.35 (16 Jul 2010 21:05:09 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 16 Jul 2010 21:05:09 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 11
Xref: news.mathworks.com comp.soft-sys.matlab:653798

"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <i1qe3f$ouh$1@fred.mathworks.com>...
> Almost the same solution, but for large size:
> 
> a=ceil(4000*rand(1e5,5));
> 
> full(sum( sparse(mod((0:numel(a)-1)',size(a,1))+1, a(:), 1) > 0,1))
> 
> % Bruno

but with a lot of unnecessary data...

     a=[ceil(10*rand(1e5,5))+100000;ceil(10*rand(1e5,5))+200000];
     r=full(sum( sparse(mod((0:numel(a)-1)',size(a,1))+1,a(:),1)>0,1));
     whos r;
%{
  Name      Size                  Bytes  Class     Attributes
  r         1x200010            1600080  double              
%}
% while
     au=unique(a);
     size(au)
%    ans = 20 1

just a pedestrian thought...
us