# sum element of columns Classic List Threaded 6 messages Open this post in threaded view
|

## sum element of columns

 a =    9   1   6    3   6   2    1   9   8 i want this: newArray=9+1+6;3+6+2;1+9+8 =15 11 18 -- Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html
Open this post in threaded view
|

## Re: sum element of columns

 On 10/16/18 2:15 AM, turbofib wrote: > a = > >     9   1   6 >     3   6   2 >     1   9   8 > > > i want this: > > > newArray=9+1+6;3+6+2;1+9+8 > > =15 11 18 > > > The sum() function takes an argument that lets you control which dimension it sums along. Try `sum(a, 2)'`. octave:4> sum(a, 2)' ans =     16   11   18 See `help sum` for details. Cheers, Andrew
Open this post in threaded view
|

## Re: sum element of columns

 In reply to this post by turbofib Am 16.10.2018 um 08:15 schrieb turbofib: > > a = > >     9   1   6 >     3   6   2 >     1   9   8 > > > i want this: > > > newArray=9+1+6;3+6+2;1+9+8 > > =15 11 18 > maybe it is time to lean matrix multiplication ? a= [9 1 6 ; 3 6 2 ; 1 9 8 ] a =     9   1   6     3   6   2     1   9   8 octave:2> b = [ 1;1;1] b =     1     1     1 octave:3> a*b ans =     16     11     18 --- Diese E-Mail wurde von Avast Antivirus-Software auf Viren geprüft. https://www.avast.com/antivirus
Open this post in threaded view
|

## Re: sum element of columns

 In reply to this post by apjanke-floss thank you i ask you another question ; a[1 4 6 3; 6 5 4 3;9 7 3 5; 3 4 1 3] i want this: 3    3+6   3+6+4  3+6+4+1   first row 3    3+4   3+4+5  3+4+5+6   second row 5    5+3   5+3+7  5+3+7+9   third row 3    3+1   3+1+4  3+1+4+3   four row result= B=[3 9 13 14;3 7 12 18;5 8 15 24;3 4 8 11]   -- Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html