Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Sum operator with 3D matrix
Replies: 4   Last Post: Apr 6, 2016 8:03 AM

 Messages: [ Previous | Next ]
 Paolo Tarpanelli Posts: 49 Registered: 1/9/06
Re: Sum operator with 3D matrix
Posted: Jan 2, 2012 5:17 AM

"Nasser M. Abbasi" <nma@12000.org> wrote in message <jdrut7\$8ba\$1@speranza.aioe.org>...
> On 1/2/2012 3:33 AM, Paolo wrote:
> > Hello,
> >
> > I have a 3D matrix m(x,y,z) and I would like to sum the 2D matrix(x,y) inside it.
> >
> > Is it possible to do it without using the For..End loop.
> > I mean, is there any possibility to use the operator<sum> which go throug the third dimension z ?
> >
> > P

>
> you mean like this?
>
> A=rand(2,2,2)
>
> A(:,:,1) =
>
> 0.9575 0.1576
> 0.9649 0.9706
>
>
> A(:,:,2) =
>
> 0.9572 0.8003
> 0.4854 0.1419
>
> ----------------------
> sum(A(:,:,:),3)
> ---------------------
>
> ans =
>
> 1.9147 0.9579
> 1.4503 1.1125
>
>
> --Nasser

Hi Nasser