matlab - 通过曲线旋转生成 3D 绘图

标签 matlab

我正在尝试旋转 2D 曲线以生成 3D 曲面图。

我尝试过使用

[X,Z,Y] = cylinder(u);
surf(X,Y,Z), axis square

然而,这使我的曲线绕错误的轴旋转。我该如何更改轴?

非常感谢。

最佳答案

要旋转圆柱体的轴,只需更改 X、Y 和 Z 的顺序即可。

[X,Y,Z] = cylinder(u);

surf(X,Y,Z) %# rotation around Z
surf(Z,X,Y) %# rotation around X
surf(Y,Z,X) %# rotation around Y

编辑

要更改曲线的旋转轴,您必须计算曲面。例如,要围绕 y 轴旋转 y = sin(alpha)alpha = 0:0.1:pi,您可以编写

r = 0:0.1:pi;
z = sin(r);
theta = 0:pi/20:2*pi;
xx = bsxfun(@times,r',cos(theta));
yy = bsxfun(@times,r',sin(theta));
zz = repmat(z',1,length(theta));
dfig,surf(xx,yy,zz)
axis equal

enter image description here

关于matlab - 通过曲线旋转生成 3D 绘图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5208447/

相关文章:

matlab - 我可以将 MATLAB 切片存储在变量中吗?

image - 在 MATLAB 中使用霍夫曼编码进行灰度图像压缩

matlab - 如何从 MATLAB 更改 HDF5 文件中的数据类型?

matlab - 关于在 MATLAB 中使用四元组

Matlab:如何通过指定 header 名称读取和提取矩阵?

image - 如何改变RGB图像的动态范围?

matlab - 如何在Matlab中连接矩阵

matlab - 在 Matlab 中更改 fprintf() 的默认 NaN 表示

windows - 无法定义具有重复名称 "DoBenchmark"的奇怪函数,因为该函数仅在一处定义

matlab - matlab 中的陷波滤波器和谐波噪声