MATLAB: Does INTERP3 complain that data is in MESHGRID format if I created it using the NDGRID format in MATLAB 7.14 (R2012a)

interpolationMATLAB

I am using NDGRID in MATLAB R2012a to generate data points for an interpolation in the following way:
[X1, X2, X3] = ndgrid(1:10,1:10, 1:10);
V = X1.^2 + X2.^2+X3.^2;
When computing the interpolation using INTERP3:
[X1q, X2q, X3q] = ndgrid(1:0.5:10,1:0.5:10, 1:0.5:10);
Vq = interp3(X1,X2,X3,V,X1q,X2q,X3q);
I receive the following error:
Error using griddedInterpolant
Data is in MESHGRID format, NDGRID format is required.
Convert your data as follows:
P = [2 1 3];
X = permute(X, P);
Y = permute(Y, P);
Z = permute(Z, P);
V = permute(V, P);
F = griddedInterpolant(X,Y,Z,V)
Error in interp3 (line 138)
F = griddedInterpolant(X, Y, Z, V, method);

Best Answer

This is a mistake in the error message of INTERP3. The error message received should say: "Data is in NDGRID format, MESHGRID format is required" instead of "Data is in MESHGRID format, NDGRID format is required".
The INTERP2 and INTERP3 functions require a sample input grid that is in MESHGRID format and the INTERPN function requires a sample input grid that is in NDGRID format. In case you want to interpolate data in NDGRID format, the INTERPN function is recommended.