2010-09-01 112 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