Path: news.mathworks.com!not-for-mail
From: "Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid>
Newsgroups: comp.soft-sys.matlab
Subject: Re: newbie seeks vectorization help
Date: Sun, 11 May 2008 06:39:05 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 39
Message-ID: <g064a9$l20$1@fred.mathworks.com>
References: <g000e3$eoi$1@fred.mathworks.com> <g053lr$rss$1@fred.mathworks.com> <g0628u$qdp$1@fred.mathworks.com>
Reply-To: "Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1210487945 21568 172.30.248.37 (11 May 2008 06:39:05 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sun, 11 May 2008 06:39:05 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: news.mathworks.com comp.soft-sys.matlab:467771


"Sky Pelletier" <skytoddk@remove14chars.vet.upenn.edu> wrote in message 
<g0628u$qdp$1@fred.mathworks.com>...
> Roger,
> 
> totalfactor = S.*(K'*I);
> 
> is exactly what I was looking for!  Thank you!  I was
> suffering from tunnel vision; having indexed into the matrix
> K in an earlier version, I was focusing on how to use the
> logical matrices S and I to index K, when in fact my
> original idea was to use them as multiplicative masks--I
> even call them S_mask and I_mask in my code!  An
> intermediate  version had S and I as index vectors, and I
> was trying so hard to figure out how to adjust that version
> while still using them as indices that I missed the obvious.
> 
> and by the way, I think my loop actually doesn't work
> because of how I misunderstood the matrix versus linear
> indexing issue.  In any event, it wasn't giving the correct
> answers when I left work Friday :)  I believe with a few
> appropriate tweaks I should be able to get it working so I
> can test which is actually faster, though I strongly suspect
> the method you proposed will prove to be the winner.
> 
> Thank you so much.  I owe you a coke.
> 
> ..Sky
------------
Hello Sky Pelletier,

  You are entirely welcome.  To tell the truth I didn't find that solution right 
away.  I was trying for a for-loop along the n=1:N direction, just in case your 
N was appreciably smaller than your M, but when I laid it out that way, the 
total vectorization method just fell into my lap, so to speak.  It was begging 
to be used, and I don't know why I hadn't seen it earlier.

Roger Stafford