MATLAB: Get mesh from surf function meshsurf 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. Best Answer 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 verticesf is an 81x4 array containing indices into v for the 81 facesc is an vector of the 100 data values which would be used for coloring the vertices Related SolutionsMATLAB: Convert patch isosurface to surf Use griddata and meshgrid MATLAB: How to plot a single valued function over a triangulated surface You can do it with patch. You'll just want to set FaceColor to interp and set the FaceVertexCData to to value of your function.But you might find it easier to use the trisurf function. Here's a simple example:npts = 100;x = 2*randn(npts,1);y = 2*randn(npts,1);z = peaks(x,y);c = z;tri = delaunay(x,y);h = trisurf(tri,x,y,z,c,'FaceColor','interp');colormap(parula(12))axis tight Related QuestionColoring of specific elements using trimeshHow to plot a wireframe mesh setting different color per edgeDoes the patch becomes blocky when I set the XData, YData or ZData properties of the patch to the values they already contained in MATLABTriangular surface
Best Answer