Torsten <
Torsten...@umsicht.fraunhofer.de> wrote in message
>
http://www.mathworks.fr/help/techdoc/ref/sph2cart.html
>
http://www.mathworks.fr/help/techdoc/ref/cart2sph.html
That was absolutely not the question of the original post!
sph2cart converts a x,y,z triplet of coordinates to a r,theta,phi triplet.
The OP (but I have the exact same problem) was asking for a way to convert a matrix of values sampled in a spherical space (at each i,j,k index of the matrix corresponds a r,theta,phi coordinate) to a cartesian space.
You would naively think to generate a uniform grid of x,y,z points, find their corresponding spherical coordinates and then do
V_cartesian = interp3 (r_start,theta_start,phi_start, V_spherical,r_cartGrid,phi_cartGrid,phi_cartGrid)
But this is not possible because:
"Error using interp3 (line 155)
X,Y,Z must be matrices produced by MESHGRID. Use TriScatteredInterp instead
of INTERP3 for scattered data."
BTW, i managed to have a working code using TriScatteredInterp but
1) I'm not sure if I TriScatteredInterp does what I really want to do.
Anyway the output is what I expect
2) It takes about 200 times what it takes for the cartesian to spherical conversion using interp3 for the same matrix sizes (on a TOP performance PC to work on a 90x90x90 matrix it takes about 80ms using interp3 for the forward conversion and 15 second for the backward conversion using TriScatteredInterp
Cheers, Luca