MATLAB: How to find the average of all rows across a series of columns

average

I am fairly new to Matlab so I'm sorry if this seems super obvious…
Have a matrix of 1000 rows, and 10 columns. How do I find the average across all the rows, and then save that column of averages into a new matrix? (this is in a loop)
EMGmatrix(:,j-1) = EMG_new; Average = mean(EMGmatrix(:,:);
Thanks!

Best Answer

You do not need a loop for this. Consider the following case:
A=randi([1 4],1000,10);%demo data
res=mean(A,2);
res variable contains the average of each row, which is 1000x1.