MATLAB: Sum over part of array without knowing array size

subset of arraysumunknown array size

I currently have a function that takes a two dimensional (2D) array as one of its inputs. Part of the function code sums over all but the first column of this input array, i.e.:
function DoSomething( Array2D, OtherInputs)
...
SumOverColumns = sum(Array2D(:, 2:end), 2);
...
end
I want to expand the use of the function so that the array can be 3D or more. However, I still want to be able so sum over all columns except the first one. I can't think of a general way to do this because I think that I need to specify ":" for every other dimension.
Any help would be much appreciated.

Best Answer

Or more? How many more dimensions? Really high dimensional arrays will be huge, so it makes little sense to have a 300 dimensional array. Even a 2- dimensional array actually has infinitely many trailing singleton dimensions. So a 5x6 array is actually implicitly of size
[5,6,1,1,1,1,1,1,1,1, ...]
Suppose you are willing to assume your array will have no more than 5 dimensions in the future. Then the trivial solution is:
SumOverColumns = sum(Array2D(:, 2:end, :, :, :), 2);
There are ways to do this with more potential dimensions, but why bother?