Borrar filtros
Borrar filtros

Plotting 3d sphere from equation

7 visualizaciones (últimos 30 días)
Khanh
Khanh el 16 de Nov. de 2011
I'm looking for a way to plot a 3d sphere given its equation.
Eg: (x-a)^2 + (y-b)^2 + (z-c)^2 <= R
I found that 'sphere' allows me to plot a unit sphere and that I can change its center using 'surf'. However, I don't see anyway to change the radius.
I haven't tried 'sphere3d', but from its documentation, it looks like I have to convert my equation to the polar coordinate system.
Is there any other function in matlab that can plot a sphere given an equation like above?
Thanks,

Respuesta aceptada

Khanh
Khanh el 16 de Nov. de 2011
Another way I can think of is using 'ellipsoid'. It will be like this:
[x,y,z] = ellipsoid(a,b,c,R,R,R);
surf(x,y,z);
Another way, I can do with 'sphere' is to scale the the surface like this:
[x,y,z] = sphere;
surf(R*x, R*y, R*z);

Más respuestas (1)

Walter Roberson
Walter Roberson el 16 de Nov. de 2011
To change the radius of sphere(), multiply all of its coordinates by R (before doing any translation.)
  2 comentarios
Khanh
Khanh el 17 de Nov. de 2011
Thanks Walter. I think that's what I mentioned above with surf(R*x, R*y, R*z), right?
Walter Roberson
Walter Roberson el 17 de Nov. de 2011
Yup.

Iniciar sesión para comentar.

Categorías

Más información sobre Surface and Mesh Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by