如何使用;气缸功能“;用Matlab创建旋转曲面?

如何使用;气缸功能“;用Matlab创建旋转曲面?,matlab,3d,geometry,Matlab,3d,Geometry,我一直在尝试用MatLab开发一个引导程序来绘制一个革命的表面,但我只是得到了错误的答案 以下是我尝试过的: b = str2double(get(handles.editB, 'string')); Incremento = str2double(get(handles.editIncrement, 'string')); x = a:Incremento:b; y = a:Incremento:b; helperFunction = get(handles.editFunction, 's

我一直在尝试用MatLab开发一个引导程序来绘制一个革命的表面,但我只是得到了错误的答案

以下是我尝试过的:

b = str2double(get(handles.editB, 'string'));
Incremento = str2double(get(handles.editIncrement, 'string'));
x = a:Incremento:b;
y = a:Incremento:b;

helperFunction = get(handles.editFunction, 'string' );
myFunction = eval(helperFunction);
[X,Y,Z] = cylinder(myFunction);
surf(Y,X,Z);
title('Surface of Revolution'); 

此外,我必须提到,前面的代码绘制函数的旋转曲面,就好像函数是反函数一样。例如:我想尝试绘制x^2的旋转曲面,然后程序将输出sqrt(x)的旋转曲面。

我认为您得到的答案是正确的,但您对该函数的期望是错误的。根据MATLAB文件:

[X,Y,Z]=圆柱体(r)
使用
r
定义轮廓曲线,返回圆柱体的X、Y和Z坐标
圆柱体
r
中的每个元素视为沿圆柱体单位高度等距分布的半径。
圆柱体周围有20个等距分布的点

换句话说,此函数将向量
r
的第一个和最后一个元素分别视为高度为0和1的圆柱体半径,并将其他元素视为此间隔内等间距高度的圆柱体半径。下图可以更好地解释这一点: