MATLAB: Is there a concise way of summing over multiple dimensions of an array

arraymultiple dimensionssum

Hello all,
Is there a concise way of summing over multiple dimensions, i.e. using just one sum function? I know if I have a defined array A, then I can do:
sum(A(:));
But what if I want to sum over a range of that array or some kind of calculated array? I would either have to use sum of sum of sum and so on to get the total sum or assign a variable to that temporary array? Thank you!

Best Answer

Example:
V = @(M) M(:);
sum( V( SomeArray(1:18, 5:43, :, 2:9) ) )