如何在 MATLAB 中获取 contour3 绘制的曲线句柄?

How to get the handle of curves plotted by contour3 in MATLAB?

当我想旋转使用contour3绘制的线条时,线条的图形句柄似乎已被删除。我怎样才能得到轮廓线的句柄?或者是否可以使用轮廓矩阵 C?

旋转线条
>> x = -2:0.25:2; x = -2:0.25:2;
>> [X,Y] = meshgrid(x);
>> Z = X.*exp(-X.^2-Y.^2);
>> C=contour3(X,Y,Z,10,'m');
>> hd=gca;
>> rotate(hd,[0 1 0],90,[0 0 0]);

输入最后一个命令后,线条没有移动。 (我使用的是 MATLAB 2016a。)

您需要从 contour3, which is the handle to the Contour graphics object 获得第二个输出:

[C, h] = contour3(...);

不幸的是,这不会帮助您解决旋转问题。来自 rotate 的文档:

rotate(h,direction,alpha) rotates the graphics object h by alpha degrees. Specify h as a surface, patch, line, text, or image object. ...

请注意 rotate 不适用于 axes or Contour objects. Instead, you'll need to alter the camera view with view