n = 100; % non-trivial case x = linspace(0,1,n).^2; y = linspace(0,1,n).^2; z = linspace(0,1,n).^2; [X,Y,Z] = ndgrid(x,y,z); % number of points to interpolate m = 1000000; xi = linspace(0,1,m); yi = linspace(0,1,m); zi = linspace(0,1,m); F = sin(3*X) .* cos(2*Y) .* sin(4*Z); tic fi = interpn(X,Y,Z,F,xi,yi,zi); toc % check sum mean(fi)