如何在Matlab中绘制球体时定义半径?

Pow*_*Pow 4 matlab geometry

我需要绘制多个球体,我正在使用来自mathwork帮助的示例代码,如下所示 -

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])
Run Code Online (Sandbox Code Playgroud)

我需要球体的半径不同.如何定义每个球体的半径?

mat*_*fee 9

[ sphere](http://www.mathworks.com.au/help/techdoc/ref/sphere.html)的帮助文件表示它为单位球体或半径为1的球体生成坐标.更改坐标为半径为1的球体到半径球体,r您只需乘以r:

[x,y,z] = sphere();
r = 5;
surf( r*x, r*y, r*z ) % sphere with radius 5 centred at (0,0,0)    
Run Code Online (Sandbox Code Playgroud)