MATLAB: How to get average of an array except considering the last element of the array

I would like to get the average of an array without considering the last element of the array.
Thanks in advance.

Best Answer

Let A - your double array
B = A(:);
out = mean(B(1:end-1));