MATLAB: How to calculate the mean of each row from several columns

columnsmeanrows

I have 3 columns as three separate variables in the workspace. I want to find the mean of each row to create a new column of averaged values.

Best Answer

a = rand(10, 1);
b = rand(10, 1);
c = rand(10, 1);
m = (a + b + c) / 3
Or less efficient:
m = mean([a, b, c], 2)