Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!b2g2000yqi.googlegroups.com!not-for-mail
From: roger <northsolomonsea@gmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Faster and vectorized
Date: Thu, 29 Oct 2009 09:22:27 -0700 (PDT)
Organization: http://groups.google.com
Lines: 24
Message-ID: <3098511b-20a6-4fcb-b56d-261c0f096dea@b2g2000yqi.googlegroups.com>
References: <hcbr1h$ne0$1@fred.mathworks.com> <618a4964-ef9e-44c8-8e1d-c9c4b73d7a14@c3g2000yqd.googlegroups.com> 
	<hcceqn$h53$1@fred.mathworks.com>
NNTP-Posting-Host: 195.193.213.214
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Trace: posting.google.com 1256833347 9297 127.0.0.1 (29 Oct 2009 16:22:27 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Thu, 29 Oct 2009 16:22:27 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: b2g2000yqi.googlegroups.com; posting-host=195.193.213.214; 
	posting-account=BbKioQoAAAAt_SMfLTBT5PYUV9nQycia
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; 
	InfoPath.1; .NET CLR 2.0.50727; .NET CLR 1.1.4322; .NET CLR 3.0.04506.648; 
	.NET CLR 3.5.21022),gzip(gfe),gzip(gfe)
Xref: news.mathworks.com comp.soft-sys.matlab:581034


On Oct 29, 5:11 pm, "Oleg Komarov" <oleg.koma...@hotmail.it> wrote:
> > losing the temp arrays may make it a bit faster. other than that
> > you'll just have to live with the fact that matlab is slow with loops.
>
> > for i = 1 : length(unC)
> >    % Index the specific class
> >     IDX = Class == unC(1,i);
>
> >     % weighted mean by row
> >     Out(2:end,i) = sum(Values(IDX).*Weights(IDX),2)./sum(Weights(IDX),
> > 2);
> > end
>
> Well i loose the matrix form of the inputs if i dont make use of the temp matrices...
> unfortunately i can't suppress them in that way.

not really sure what you mean by that, if you intialize them the right
way it shouldn't make a difference.
Out(IDX,i) = ... may work in that sense. In fact if you make sure the
matrices are intialized the right way you may be able to make IDX a
matrix and use a matrix index into matrices.