Convert surface data to patch data
fvc = surf2patch(Z)
fvc = surf2patch(Z,C)
fvc = surf2patch(X,Y,Z)
fvc = surf2patch(X,Y,Z,C)
fvc = surf2patch(...,'triangles')
[f,v,c] = surf2patch(...)
fvc = surf2patch(h)
converts the geometry and color data from the surface object identified by the handle h into patch format and returns the face, vertex, and color data in the struct fvc. You can pass this struct directly to the patch command.
fvc = surf2patch(Z) calculates the patch data from the surface's ZData matrix Z.
The first example uses the sphere command to generate the XData, YData, and ZData of a surface, which is then converted to a patch. Note that the ZData (z) is passed to surf2patch as both the third and fourth arguments — the third argument is the ZData and the fourth argument is taken as the CData. This is because the patch command does not automatically use the z-coordinate data for the color data, as does the surface command.
[x y z] = sphere; patch(surf2patch(x,y,z,z)); shading faceted; view(3)
In the second example surf2patch calculates face, vertex, and color data from a surface whose handle has been passed as an argument.
s = surf(peaks); pause patch(surf2patch(s)); delete(s) shading faceted; view(3)