Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Double sum question
Date: Thu, 17 Jun 2010 16:12:20 +0000 (UTC)
Organization: Xoran Technologies
Lines: 26
Message-ID: <hvdhh4$fqq$1@fred.mathworks.com>
References: <34f86e08-19ab-49a9-a3c0-e908bd93de65@j12g2000pri.googlegroups.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1276791140 16218 172.30.248.37 (17 Jun 2010 16:12:20 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 17 Jun 2010 16:12:20 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1440443
Xref: news.mathworks.com comp.soft-sys.matlab:645819

Marios Karaoulis <marios.karaoulis@gmail.com> wrote in message <34f86e08-19ab-49a9-a3c0-e908bd93de65@j12g2000pri.googlegroups.com>...
> I can't find a quick way to execute the following double sum.
> 
> i=integer
> j=integer
> b_node 3x1 vector
> c_node 3x1 vector
> 
> 
> %  sum
> x_flux1=((a(i,a1)*b_node(1)+a(i,a2)*b_node(2)+a(i,a3)*b_node(3)));
> x_flux2=((a(j,a1)*b_node(1)+a(j,a2)*b_node(2)+a(j,a3)*b_node(3)));
> 
> y_flux1=((a(i,a1)*c_node(1)+a(i,a2)*c_node(2)+a(i,a3)*c_node(3)));
> y_flux2=((a(j,a1)*c_node(1)+a(j,a2)*c_node(2)+a(j,a3)*c_node(3)));
> 
> 
> jam2=x_flux1*x_flux2+y_flux1*y_flux2;
===============

Looks like you want the following

A=[a(i,a1),  a(i,a2), a(i,a3);
  a(j,a1),  a(j,a2), a(j,a3)];

jam2=sum(  prod( A*[b_node,c_node], 1 )  );