
If you permute them then and then you show them with a plotting tool that takes into account that the input has to be permuted. dim1 is supposed to remain dim1 and dim2 to remain dim2!!!! Whatever you want to do afterwards with the matrices you're working with. Interesting! And very fine for me! But still I don't get why to switch dimensions when interpolating matrices. > That causes the trouble to you forty years later. > And Why FORTRAN? Because the best numerical algorithm is written in this language when MATLAB was born. > And why column wise? Because MATLAB is historical originated from FORTRAN.

> And why Y/X you ask? Because MATLAB has data ranged column wise and not the opposite? Am I supposed here to use meshgrid to switch dimension 1 and dimension 2 so that interp3 can switch them again? Isn't it silly? And when I used it I always got problems.
MATLABE PERMUTE CODE
Or should I be using meshgrid before instead of ndgrid? I pruned all the possible meshgrids in my code as I can't get the reason to switch dimension 1 and dimension 2. Is interp3 switching X and Y just for the fun of it? If I switch origin(1) with origin(2) and viceversa everything looks correct. SphericalData = interp3 (double(cartesianData),X,Y,Z,'linear',0) Īnd I get something extremely odd. I know this calculation are correct, checked the results lots of times. origin(1) is the center along the first dimension of the matrix, origin(2) is the center along the second one and so on. I have calculated the center of this sphere and I've called it origin. This field contains something shaped like a sphere, with its center displaced by the center of the matrix. I want to convert a vector field to spherical coordinates.

I only know that sometimes I get unpredictible results with errors that are extremely difficult to point out if I use meshgrid. Ok, I already admit I never _fully_ got the deal with meshgrid/ndgrid.
