MATLAB: Taking average of 3 rows from a matrix

averagematrix

I have a data that has 10 columns and 369 rows.
I would like to get average of every 3 rows so that the output will be 10 columns 123 rows.
So that I will be getting average of first three rows in the first row in the output spreadsheet.
Thank you in advance.

Best Answer

Simpler and faster than the other two:
[m,n]=size(A); % A is your matrix
Mean=reshape(mean(reshape(A,3,[])),[],n)