create a mesh from the "scatter3" command

조회 수: 15 (최근 30일)
Alberto Acri
Alberto Acri 2020년 12월 26일
댓글: Walter Roberson 2020년 12월 27일
Is it possible to create a mesh from the "scatter3" command (and keep the colors on the mesh) ?

답변 (1개)

Walter Roberson
Walter Roberson 2020년 12월 27일
Yes, it is possible. If you record the handle of the scatter3(), then you can fetch the XData, YData, ZData and CData properties to give the coordinates of the points (but it would have been easier to just use the expressions you passed to scatter3() )
Once you have the coordinates, you can use https://www.mathworks.com/help/matlab/ref/delaunay.html delaunay() to produce a triangulation. You can then trimesh() to plot it:
T = delaunay(x, y, z);
h = trimesh(T, x, y, z, c, 'FaceColor', 'none');
  댓글 수: 2
Alberto Acri
Alberto Acri 2020년 12월 27일
I didn't get what I wanted.
Walter Roberson
Walter Roberson 2020년 12월 27일
Perhaps you should describe the difference between what you wanted and what you obtained. Attaching data and sample plots would help.
Note: it is common that when you have scattered points in 3 space that triangulation ends up joining what you are thinking of as being in different "layers". It is also common for points to end up joined across ends of a curve when you are only expecting joining along the curve.
Remember that the order of points in scatter3 does not give any information about how the points are joined. If you have information about how the points are joined, then you should use that information instead of fetching information from scatter3.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by