Path: news.mathworks.com!not-for-mail
From: "b b" <bogey4@gmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Bogey
Date: Sun, 26 Oct 2008 20:55:04 +0000 (UTC)
Organization: university of Guelph
Lines: 34
Message-ID: <ge2lf8$dbb$1@fred.mathworks.com>
References: <gdvjlp$kij$1@fred.mathworks.com> <gdvoje$gnn$1@fred.mathworks.com> <gdvq28$482$1@fred.mathworks.com> <ge0231$lu$1@fred.mathworks.com> <ge2b76$msj$1@fred.mathworks.com> <ge2dju$bjg$1@fred.mathworks.com> <ge2jbm$q98$1@fred.mathworks.com>
Reply-To: "b b" <bogey4@gmail.com>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1225054504 13675 172.30.248.38 (26 Oct 2008 20:55:04 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sun, 26 Oct 2008 20:55:04 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 944946
Xref: news.mathworks.com comp.soft-sys.matlab:497329

Thanks Bruno,

I'm still wrapping my head around how this works, but the results are correct.  FYI, on a slightly larger dataset (N=137 vs N=4), the times are a bit faster with the loop method, although I was more interested in learning to program without loops, so this is great.


Elapsed time is 0.004989 seconds. (Loop)
Elapsed time is 0.008515 seconds.(ndgrid)


Thanks again,

Bruce
"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <ge2jbm$q98$1@fred.mathworks.com>...
> "b b" <bogey4@gmail.com> wrote in message <ge2dju$bjg$1@fred.mathworks.com>...
> 
> > 
> > Any ideas?
> 
> Here is one:
> 
> X = [1 2 3 4;
>      5 4 3 2];
> ksi = [ 1 2 2 1;
>        2 3 3 2;
>        1 3 5 1;
>        1 2 2 2];
> muEst = [2 3 4 5;
>          6 5 4 4];
> 
> % Engine
> [N I]=ndgrid(1:4,1:4);
> tot = sum((X(:,N)-muEst(:,I)).^2,1) * ksi(:)
> 
> % Bruno