我需要绘制具有不同半径的圆顶(或半球)。我被告知如何在上一个问题上绘制shpere:
[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组件的高度都不同。
如何更改代码?
答案 0 :(得分:2)
我们分别在x,y和z rx
,ry
和rz
中调用半径。
然后你调用这个函数
[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