MATLAB: How to get rid of error

multidimensional array

if i run the command A = sum(B,5) i am not getting the correct result.
where B is [4*4*5] % 4*4 matrix with dimension 5. so A should be [4*4] .
but i am getting A as [4*4*5]. please help me to solve this issue.

Best Answer

I believe ‘A’ has dimension 3 by your description.
Try this:
A = sum(B,3);
That will sum across the third dimension, giving you ‘A’ as a (4x4) 2D matrix.
Related Question