我试图在z = 0.5处绘制一条线,用于下面的surf图。 代码很简单,但现在我想在surf图中包含一条线,例如0.5。 我的参数是Xq , Yq和Vq ,我输入到MATLAB的surf命令中。 Xq , Yq和Vq都是meshgrid生成的meshgrid矩阵。 在给定特定公差的情况下,我发现Vq的点等于0.5,并且我用x和y坐标离开了find命令,但是我从这里开始输了。
完成此任务的最佳方法是什么?
I am trying to draw a line at z=0.5 for the following surf plot. The code is simple enough but now I want to include a line in the surf plot at 0.5 for example. My parameters are Xq, Yq and Vq, which I input into the surf command of MATLAB. Xq, Yq and Vq are all 2001x4001 matrices produced by meshgrid. I find the points in Vq equal to 0.5 given a particular tolerance, and I get out of the find command with and x and y coordinate, but I am lost from here on out.
What is the best way to accomplish this?
最满意答案
您可以使用contour3绘制表面等于0.5的线。 您可以使用第四个输入参数指定您想要Vq为0.5的3D线。
% Load in some sample data [Xq, Yq, Vq] = peaks(); % Plot your surface surf(Xq, Yq, Vq, 'EdgeColor', 'none'); hold on % Now plot the 3D contour contour3(Xq, Yq, Vq, [0.5 0.5], 'k');
如果要获取与该轮廓关联的Xq和Yq值,可以使用输出调用contour3 ,该输出将返回与轮廓关联的ContourMatrix
values = contour3(Xq, Yq, Vq, [0.5 0.5], 'k');You can use contour3 to draw a line where your surface is equal to 0.5. You can specify that you want the 3D line where Vq is 0.5 by using the fourth input argument.
% Load in some sample data [Xq, Yq, Vq] = peaks(); % Plot your surface surf(Xq, Yq, Vq, 'EdgeColor', 'none'); hold on % Now plot the 3D contour contour3(Xq, Yq, Vq, [0.5 0.5], 'k');If you want to get the Xq and Yq values that are associated with that contour, you can call contour3 with an output which will return a ContourMatrix associated with the contour
values = contour3(Xq, Yq, Vq, [0.5 0.5], 'k');更多推荐
发布评论