如何绘制最小值和最大值沿着z轴在matlab上给定的二维图?

tag5nh1u  于 2023-10-23  发布在  Matlab
关注(0)|答案(1)|浏览(167)

我试图在matlab中沿着z轴绘制两个值min和max。基本上,我感兴趣的是头部的高度,因此我希望在图上的最小值和最大值。我的方法是首先将3D网格投影到2D平面上,然后沿沿着z轴(Vertices(:,3))找到最小值和最大值。我找到了最小值和最大值,但我无法绘制它。我知道它与plot函数中的[0,1]或[1,0]有关。有人能帮帮我吗。我还添加了一个图,显示我感兴趣的点。
先谢了。

clc;
    clear all;

    mesh = readSurfaceMesh("Mesh.ply");

    Vertices=mesh.Vertices;
    Faces=mesh.Faces;

    min=min(Vertices(:,3));
    max=max(Vertices(:,3));

   figure;
   p=patch('Faces',Faces,'Vertices',Vertices);
   view(0,0); %Head Depth-Side View

   hold("on");

   plot([min, min], [0,1], 'ro', 'LineWidth', 2); % I am stuck here
   plot([max, max], [1, 0], 'go', 'LineWidth', 2); %I am stuck here
a64a0gku

a64a0gku1#

% You don't need the value of the min and max, you need their position
% in the array
[~, posmin] = min(Vertices(:,3));  
[~, posMAX] = max(Vertices(:,3));
% Also, Don't call a variable "min" or or "max", you won't be able to 
% call the min() and max() functions anymore!

figure;
p=patch('Faces',Faces,'Vertices',Vertices);
view(0,0); %Head Depth-Side View

hold("on");

% Plot the 3D max and min Vertices
plot3(Vertices(posmin,1), Vertices(posmin,2), Vertices(posmin,3), 'ro');
plot3(Vertices(posMAX,1), Vertices(posMAX,2), Vertices(posMAX,3), 'go');

相关问题