I need to plot multiple sphere and I was using the example code from mathwork help as follows -
figure
[x,y,z] = sphere();
surf(x,y,z) % sphere centered at origin
hold on
surf(x+3,y-2,z) % sphere centered at (3,-2,0)
surf(x,y+1,z-3) % sphere centered at (0,1,-3)
daspect([1 1 1])
I need the spheres to be different radius. How can I define radius for each of these spheres?
The helpfile for [sphere
] (http://www.mathworks.com.au/help/techdoc/ref/sphere.html) says that it generates coordinates for a unit sphere, or a sphere of radius 1. To change coordinates for a sphere of radius 1 to a sphere of radius r
you just multiply them by r
:
[x,y,z] = sphere();
r = 5;
surf( r*x, r*y, r*z ) % sphere with radius 5 centred at (0,0,0)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With