MATLAB: Reshape and sum multi-dimensional matrix

matrixmultidimensionalreshapesum

Hi, I have a 20-by-30-by-40 matrix. I would like to sum each two page of the third dimension. In the end, I need to have a 20-by-30-by-20 matrix.
I appreciate if you could help me.

Best Answer

Where A is your array:
A(:,:,1:2:end) + A(:,:,2:2:end)