create a mesh from the "scatter3" command

18 vues (au cours des 30 derniers jours)
Alberto Acri
Alberto Acri le 26 Déc 2020
Commenté : Walter Roberson le 27 Déc 2020
Is it possible to create a mesh from the "scatter3" command (and keep the colors on the mesh) ?

Réponses (1)

Walter Roberson
Walter Roberson le 27 Déc 2020
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 commentaires
Alberto Acri
Alberto Acri le 27 Déc 2020
I didn't get what I wanted.
Walter Roberson
Walter Roberson le 27 Déc 2020
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.

Connectez-vous pour commenter.

Produits


Version

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by