MATLAB: Averaging the data from a 3d matrix and populating it in a 2D matrix.

3d matrixaverage over 3rd dimensionMATLAB

I have a problem. I have a 3D matrix, lets say A(15,8,40) and I want to get a new matrix, lets say B(15,8) where every row in matrix B will have the mean value of that row, averaged over the third dimension, in this case 40. How can I do that?

Best Answer

B = mean(A,3);