MATLAB: How to average a three dimensional matrix at each level

matrixmatrix manipulation

Sir, I have a matrix of dimension (40*40*16)which are for latitude, longitude and altitude. I need to average over latitude and longitude for each altitude so that i can get the resultant matrix of dimension (1*16). Please help me.
thanks

Best Answer

a=rand(40,40,16) % Example
out=squeeze(mean(mean(a)))