From: Ulrik Nash on
Hi Everyone,

Ssuppose I have a matrix A as follows:

A =

1 1
2 2
3 3

Now I wish to sum horzontally, to obtain B

B = 2
4
6

How can I do this without needing to transpose A. Is it possible?

Regards,

Ulrik.
From: Pekka Kumpulainen on
"Ulrik Nash" <uwn(a)sam.sdu.dk> wrote in message <hrp16c$a9o$1(a)fred.mathworks.com>...
> Hi Everyone,
>
> Ssuppose I have a matrix A as follows:
>
> A =
>
> 1 1
> 2 2
> 3 3
>
> Now I wish to sum horzontally, to obtain B
>
> B = 2
> 4
> 6
>
> How can I do this without needing to transpose A. Is it possible?
>
> Regards,
>
> Ulrik.

RTM
doc sum
B = sum(A,dim) sums along the dimension of A specified by scalar dim.