0

Is there any way to do a symbolic transformation from Cartesian to spherical. I could do:

x = r * sin(theta)*cos(phi)

And so on, and then plug into an expression of x,y and z. Is there any easier command to do this?

Eitan T
  • 32,660
  • 14
  • 72
  • 109
yankeefan11
  • 485
  • 1
  • 6
  • 18

1 Answers1

2

I'm not sure if cart2sph can do the conversion on symbolic objects, but its documentation has the mapping conveniently spelled out for you:

phi = atan2(y, x);
theta = atan2(z, sqrt(x .^ 2 + y .^ 2));
r = sqrt(x .^ 2 + y .^ 2 + z .^ 2);

I think you'll have to resort to this explicit transformation.

Eitan T
  • 32,660
  • 14
  • 72
  • 109