Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: trying to avoid using a for loop
Date: Sat, 25 Oct 2008 18:52:01 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 19
Message-ID: <gdvpsh$26q$1@fred.mathworks.com>
Reply-To: <HIDDEN>
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 1224960721 2266 172.30.248.38 (25 Oct 2008 18:52:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sat, 25 Oct 2008 18:52:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1059365
Xref: news.mathworks.com comp.soft-sys.matlab:497226


Hi.

I am trying to compute S.
S is a m by m matrix.  

To create S, I use the following information.

G is a m by N matrix.
G(:,i) is the ith column of G.
g_bar is a m by 1 vector.

This for-loop can compute S.
S=[];
for i=1:N
     x=G(:,i)-g_bar;
     S=S+(x*x'); 
end

I am wondering if there is a way to compute S without the for-loop.  Thanks.