MATLAB: Calculation the mean of a portion of a matrix

MATLABmatrix edges

Hello!
I am having trouble finding out how can I calculate the mean of all the values in a 10×10 matrix (z) which do not lie along an edge of that same matrix (z)…
Thanks in advance!

Best Answer

mean( z(2:end-1,2:end-1) ,'all')