MATLAB: Matrix manipulation,want to find mean value

matlab codermatrix manipulation

having matrix W. its size is 7×50. totally 350 elements. in this column'1' have to find mean value of 4 elements then subtracts this value with remaining mean value of 3 elements. want to get this mean value up to 50 columns.how to implement this?

Best Answer

"subtracts this with" ? .
Try something like
.
homeworkVec = mean(W(1:4,:),1)-mean(W(5:7,1),1);
In mean(x,1), the "1" is default. I just put it in to be explicit.
homeworkVec = mean(W(1:4,:))-mean(W(5:7,1));