Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!s1g2000prd.googlegroups.com!not-for-mail
From: Bob Alvarez <ralvarez@spambob.net>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Help in vectorizing code
Date: Mon, 27 Apr 2009 17:53:11 -0700 (PDT)
Organization: http://groups.google.com
Lines: 13
Message-ID: <128ed907-11c6-4e7a-a67a-736ececef060@s1g2000prd.googlegroups.com>
References: <1e6f5074-edce-417a-b0a5-b62db0fb033f@w31g2000prd.googlegroups.com> 
	<02cd4c0a-d994-4a8b-8dba-7c3bf32fce96@c18g2000prh.googlegroups.com>
NNTP-Posting-Host: 216.103.212.87
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Trace: posting.google.com 1240879992 20113 127.0.0.1 (28 Apr 2009 00:53:12 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Tue, 28 Apr 2009 00:53:12 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: s1g2000prd.googlegroups.com; posting-host=216.103.212.87; 
	posting-account=pNrldAoAAAB5GlVBDJqvQa-_ca5yFHCO
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.9) 
	Gecko/2009040821 Firefox/3.0.9 (.NET CLR 3.5.30729),gzip(gfe),gzip(gfe)
Xref: news.mathworks.com comp.soft-sys.matlab:535823

On Apr 27, 12:42=A0pm, jrenfree <jrenf...@gmail.com> wrote:
> I'm not real sure how to do it using the idxs variable you create. =A0If
> you have a way of making it more of a logical matrix, then it's easy:
>
> idxs =3D [1 0 0 0 0;1 1 0 0 0;1 1 0 0 0;1 1 1 0 0;1 1 1 0 0];
> sum(d.*idxs,2)

The idxs are actually samples of a poisson random variable. I did try
to make a mask array using poly2mask from the image processing
toolbox, but that is slower than doing the loop :-(