在特定z值的曲面图中添加一条线(Add a line to a surface plot at a particular z value)

编程入门 行业动态 更新时间:2024-10-23 22:27:56
在特定z值的曲面图中添加一条线(Add a line to a surface plot at a particular z value)

我试图在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');

enter image description here

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');

更多推荐

本文发布于:2023-04-28 03:46:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1330270.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:曲面   图中   一条线   在特定   surface

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!