%MVAVERAGE2 Smooths a matrix through the moving average method.
% Y = MVAVERAGE2(X,F,G) quickly smooths a 2-D signal X via averaging
% each sampling point with their surrounding samples that fit in a
% submatrix (2R+1)x(2C+1).
% Y = MVAVERAGE(X,R), uses R=C.
% Y = MVAVERAGE(X), uses R=C=1 by default, it means a 3x3 box.
% Example (from M.S. Carlos Adrin Vargas Aguilera)
% [X,Y] = meshgrid(-2:.2:2,3:-.2:-2);
% Zi = 5*X.*exp(-X.^2-Y.^2);
% Zr = Zi + rand(size(Zi));
% Zs = mvaverage2(Zr,2,3);
% subplot(131), surf(X,Y,Zi)
% view(2), shading interp, xlabel('Z')
% subplot(132), surf(X,Y,Zr)
% view(2), shading interp, xlabel('Z + noise')
% subplot(133), surf(X,Y,Zs)
% view(2), shading interp, xlabel('Z smoothed')
% See also MVAVERAGE and MVAVERAGEC
% by Yi Cao
% Cranfield University