开发者

How to plot a dome in MATLAB w/ different radii?

开发者 https://www.devze.com 2023-01-14 15:55 出处:网络
I need to plot a dome (or half sphere) that have different radii. I was told how to plot the shpere on a previous question:

I need to plot a dome (or half sphere) that have different radii. I was told how to plot the shpere on a previous question:

[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 
a开发者_Go百科xis 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?

But I need the height of the x, y, and z components to all be different.

How do I change the code?


Let's call the radius in x, y, and z rx, ry, and rz, respectively.

Then you call the function like this

[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

精彩评论

暂无评论...
验证码 换一张
取 消