Mesh

Export MATLAB 3D data

In MATLAB there are many functions to visualize data .Two functions that are generally used to plot 3d data is surf and mesh.surf() and mesh() uses three 2d arrays to plot data. Each array contain x,y and z coordinates of surface.The 3d data of surface can be saved to many different file formats.The file would contain vertices and faces of surface. MATLAB file exchange has a number of submissions which can export mesh in VRML,OBJ,STL and other file formats. A surface is made up of number of small triangles or rectangles. To get these one can use function surf2patch().This function will convert x,y,z data to face and vertex data. Face data is a m-by-4 array , it means every patch of the surface is made by connecting four vertex . Vertex is a n-by-3 array. Each row of vertex array is a 3d point of surface .

Export MATLAB surface to OBJ file

The following MATLAB code can be used to export 3d surface to Wavefront OBJ file. OBJ file will contain only vertex and face data of the surface. Download surf2OBJ

[x,y,z]=peaks;

surf2OBJ(x,y,z,'OBJfileName'); %OBJfileName.obj will be created

Export MATLAB surface to POV-Ray mesh

This following MATLAB code export 3d surface to POV-Ray mesh. The POV-Ray file will contain only vertex and face data of the surface. More detailed explanation is given in surf2PovMesh.m file. Download surf2PovMesh

[x,y,z] = peaks;

surf2PovMesh(x,y,z,'povMeshName.pov'); %povMeshName.pov will be created