How to get the mean of rows of a matrix in Octave?

B Seven picture B Seven · Jan 31, 2012 · Viewed 26.6k times · Source
>> a = [2,3,4;6,7,8]
a =

   2   3   4
   6   7   8

>> mean(a)
ans =

   4   5   6

where [4 5 6] is the mean for each column

How can I get the mean for each row?

In my example, I would expect [3;7]

Answer

NPE picture NPE · Jan 31, 2012

From http://www.mathworks.co.uk/help/techdoc/ref/mean.html:

For matrices, mean(A,2) is a column vector containing the mean value of each row.

In Octave it's the same.