2010-09-01 88 views
1

我需要绘制具有不同半径的圆顶(或半球)。有人告诉我如何绘制在前面的问题的shpere:如何绘制一个圆顶在MATLAB /不同半径?

[x,y,z] = sphere;  %# Makes a 21-by-21 point sphere 
x = x(11:end,:);  %# Keep top 11 x points 
y = y(11:end,:);  %# Keep top 11 y points 
z = z(11:end,:);  %# Keep top 11 z points 
r = 3;     %# A radius value 
surf(r.*x,r.*y,r.*z); %# Plot the surface 
axis equal;   %# Make the scaling on the x, y, and z axes equal 

Does anyone know how to plot a dome (aka half sphere) in MATLAB...or anyother programming language?

但我需要在x,y和z分量所有的高度是不同的。

如何更改代码?

回答

2

我们分别称x,y和z的半径为rx,ryrz

然后调用这个

[x,y,z] = sphere;  %# Makes a 21-by-21 point unit sphere 
x = x(11:end,:);  %# Keep top 11 x points 
y = y(11:end,:);  %# Keep top 11 y points 
z = z(11:end,:);  %# Keep top 11 z points 
rx = 3;ry = 4;rz = 9; %# Define rx, ry, rz 
surf(rx*x,ry*y,rz*z); %# Plot the surface, multiplying unit coordinates with radii 
axis equal;   %# Make the scaling on the x, y, and z axes equal 
+0

感谢的功能等!!!!!!这很好用! – dewalla 2010-09-01 16:05:57

相关问题