dim — Dimension to operate along Dimension dim indicates the dimension whose length reduces to 1 . The size(M,dim) is 1 , while the sizes of all other dimensions remain the same. Consider an m -by- n input matrix, A : mean(A,1) computes the mean of the elements in each column of A and returns a 1 -by- n row vector.