get mesh from surf function

10 ビュー (過去 30 日間)
Albi
Albi 2015 年 9 月 3 日
コメント済み: Albi 2015 年 9 月 4 日
Is there a way to get the mesh which the function "surf" produces? By that I mean I need the usual mesh format which is a list of vertices and a list of faces.

採用された回答

Mike Garrity
Mike Garrity 2015 年 9 月 4 日
Yes, the surf2patch command.
[x,y,z] = peaks(10);
h = surf(x,y,z);
[f,v,c] = surf2patch(h);
At this point:
  • v is a 100x3 array containing the 100 vertices
  • f is an 81x4 array containing indices into v for the 81 faces
  • c is an vector of the 100 data values which would be used for coloring the vertices
  1 件のコメント
Albi
Albi 2015 年 9 月 4 日
Exactly what I was looking for. Thank you.

サインインしてコメントする。

その他の回答 (1 件)

Adam
Adam 2015 年 9 月 3 日
If you mean the X, Y and Z meshes that define the surface then the XData, YData and ZData properties of the surface object contain these and the CData contains the colour data for the ZData values.
  3 件のコメント
Adam
Adam 2015 年 9 月 3 日
I'm not too familiar with mesh definitions, but FaceNormals and VertexNormals seem to be the only other sets of data you can extract from a surface object but they are m-by-n-by-3 arrays.
Albi
Albi 2015 年 9 月 3 日
Yeah, I checked the properties and found nothing I could use. Looking at the surf doc page, I saw that they briefly explain the algorithm behind the surf function. I could write it myself, but it would be nice to have it for free. Looks like surf can be used only for visualization purposes.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by