2014-11-14 186 views
0

我必须在特定的坐标上绘制具有给定高度和半径的圆锥。如何绘制给定高度和半径的圆锥

MATLAB有函数cylinder(r),但它只绘制一个单位圆柱体,而我需要它是一个特定的高度。

没有其他链接指定如何绘制高度“h”的锥体。

+2

所以,你想画一个圆柱体或锥体? – rayryeng 2014-11-15 07:15:31

回答

0

Matlab的cylinder可用于通过指定减小到0的半径绘制圆锥。高度仅为z缩放因子。 (半径也可以实现为x,y比例因子,但cylinder函数允许直接指定半径值,因此不需要)。

R = 1; %// radius 
H = 3; %// height 
N = 100; %// number of points to define the circumference 
[x, y, z] = cylinder([0 R], N); 
mesh(x, y, H*z) 

enter image description here

+0

非常感谢! – 2014-11-14 21:59:38

+0

你也应该改变你的问题:这是你想要的_cone_还是_cylinder_? – 2014-11-14 22:00:14

+0

我想要一个圆锥体。基本上,缩放因子是我无法想到的。 – 2014-11-14 22:04:40

0

[x y z]随高度h,半径r圆柱体,

x = 10; 
y = 20; 
z = 5; 
h = 10; 
r = 1; 
[X,Y,Z] = cylinder(r,30); 
X = X + x; 
Y = Y + y; 
Z = Z*h + z; 
surf(X,Y,Z) 

enter image description here

相关问题