Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: add all the dimensions
Date: Fri, 4 Sep 2009 04:05:20 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 31
Message-ID: <h7q3m0$nlo$1@fred.mathworks.com>
References: <h7q2pb$qen$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1252037120 24248 172.30.248.35 (4 Sep 2009 04:05:20 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 4 Sep 2009 04:05:20 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1875128
Xref: news.mathworks.com comp.soft-sys.matlab:568273


Got it! sum(a,3)
"Diego Lass" <dlISCool@gmail.com> wrote in message <h7q2pb$qen$1@fred.mathworks.com>...
> Hi
> 
> I am trying to add the matrices of different dimension together,  ex
> 
> a(:,:,1)= 
> 1 2 3
> 4 5 6
> 
> a(:,:,2) = 
> 0 0 0
> 0 0 1
> 
> a(:,:,3) = 
> 1 0 0
> 0 0 0
> 
> some function later gives
> b =
> 2 2 3
> 4 5 7 
> 
> what is the most efficient way of doing this?
> 
> Thanks!
> Diego 
> 
> 
> 
>