How can I calculate the mean of a group of rows and put the in a matrix such as:
1 4 5
1 34 4
1 65 0
1 5 3
2 3 44
2 52 4
2 5 6
3 9 2
3 9 1
3 9 9
So I can have a matrix as
1 27 4
2 20 18
3 9 4
Thx
How can I calculate the mean of a group of rows and put the in a matrix such as:
1 4 5
1 34 4
1 65 0
1 5 3
2 3 44
2 52 4
2 5 6
3 9 2
3 9 1
3 9 9
So I can have a matrix as
1 27 4
2 20 18
3 9 4
Thx
Assuming original data is in matrix A
:
indx=unique(A(:,1));
for ii=1:numel(indx)
RowMean(ii,:)=mean(A(1,:)==indx(ii),:);
end