Mean and sum functions return wrong array type
Reported by Peter Drummond
BUG DESCRIPTION:
----------------
The mean and sum functions return the wrong array type when processing an n dimensional array and summing the last element with n>3. They should return an n dimensional array in which the first n-1 dimensions are unchanged, and the last dimension is one, according to the documentation. Instead, the lower dimensions are scrambled into the wrong order.
ERROR LOG:
----------
HOW TO REPRODUCE THE BUG:
-------------------------
The bug is easily replicated from the terminal. Enter a = ones(1,2,3,4), then m = mean(a,4). The output should be ones(1,2,3,1). Instead, it is:
m =
(:,:,1)
1.
1.
1.
(:,:,2)
1.
1.
1.
This is the same as ones(3,1,2), which is the wrong dimension.
OTHER INFORMATION:
------------------