MATLAB: Confusion with interp3 and interpn

interp3?MATLAB

Hi,
According to my teacher, "for a matrix indexed as [M, N, P], the axis variables must be given in the order N, M, P" in relation to the swaping of variables at the interp3 line:
[X, Y, Z] = size(data);
ts= [20 30 20]
[x, y, z] = ndgrid((1:X)/X, (1:Y)/Y, (1:Z)/Z);
[x2, y2, z2] = ndgrid((1:ts(1))/(ts(1)), (1:ts(2))/(ts(2)), (1:ts(3))/(ts(3)));
test1= interp3(y, x, z, data, y2, x2, z2, 'linear');
However, I couldn't find this info on the function's page, nor it makes any sense to me (even though the computation seems correct!).
Any help welcome, thank you,
TS

Best Answer

I think reading through this documentation page may be of use to you, especially the examples in the Grid Representation section.