Path: news.mathworks.com!not-for-mail
From: "b b" <bogey4@gmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Bogey
Date: Sat, 25 Oct 2008 17:06:01 +0000 (UTC)
Organization: university of Guelph
Lines: 26
Message-ID: <gdvjlp$kij$1@fred.mathworks.com>
Reply-To: "b b" <bogey4@gmail.com>
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 1224954361 21075 172.30.248.37 (25 Oct 2008 17:06:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sat, 25 Oct 2008 17:06:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 944946
Xref: news.mathworks.com comp.soft-sys.matlab:497219


Hi, 

I'm trying to avoid using loops when multiplying matrices together iteratively and was wondering if anyone has a trick to do this quickly and without loops.  My algebra skills are somewhat lacking, so hopefully this is straightforward!

X = [1 2; 5 4];
Y = [1 2 1 ;2 4 1];
ksi = [1 2 ;2 3];

Here's the equation that I'm attempting to solve:
    \sum_{n=1}^N\sum_{i=1}^M \xi_{ni}X_nY_i
where a Xn would be a column (e.g. [1;5]) and a Yi would be a row (e.g. [1 2 1]).  We should end up with a 2x3 matrix.

Here's the code I'm currently using:

tot = zeros(2,3);
for n = 1:2,
  for i = 1:2,
    tot = tot+ X(:,n)*Y(i,:);
  end;
end;

Does anyone have a suggestion how to do this without these loops? These matrices are quite big in the actual program, and this section takes a long time to run.

Thanks!

Bruce