x = rand(4, 5, 3);
x(2, 3, 1) = NaN;
x(4, 3, 2) = NaN;
xx = squeeze(x(:, :, 1))
extrapolate(xx)
mid = xx(1:3, 2:4);
mid = nanmean(mid(:))
x
extrapolate(x)
mid = x(1:3, 2:4, 1);
mid = nanmean(mid(:))
mid = x(3:4, 2:4, 2);
mid = nanmean(mid(:))
