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 19:40:24 +0000 (UTC)
Organization: Universit&#228;tsSpital Z&#252;rich
Lines: 23
Message-ID: <i1qcj8$idl$1@fred.mathworks.com>
References: <i1q7ng$78g$1@fred.mathworks.com> <i1q9c0$li7$1@fred.mathworks.com> <i1qb9c$oo4$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1279309224 18869 172.30.248.38 (16 Jul 2010 19:40:24 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 16 Jul 2010 19:40:24 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 11
Xref: news.mathworks.com comp.soft-sys.matlab:653774

"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <i1qb9c$oo4$1@fred.mathworks.com>...
> Another solution:
> 
> a=[1 2 2;
> 2 3 3;
> 1 4 5];
> 
> sum(accumarray([mod((0:numel(a)-1)',size(a,1))+1 a(:)],1)>0)
> 
> Bruno

the problem with all these nice solutions
- given the OP's mat size...

     a=ceil(4000*rand(1e5,5));
     sum(accumarray([mod((0:numel(a)-1)',size(a,1))+1 a(:)],1)>0)
%{
??? Error using ==> accumarray
Out of memory. Type HELP MEMORY for your options.
%}
%    same with the HISTC approach...

us