Export triangulation to Paraview
Updated 5 May 2009
Trying to visualize a huge triangulation with trisurf or triplot is often very slow and frustrating. Solution : use Paraview, a very powerful and free 3D data viewer. But it could be complicated to generate the input file specially with binary format. The function proposed takes a 2.5D unrestricted triangulation and generates the ASCII VTK file for Paraview.
"dir" is the path of the directory where the file is saved (string). (Optional)
"file" is the name without extension of the file (string).
"XYZ" is the coordinate of the vertex of the triangulation (nx3 matrix).
"tri" is the list of triangles which contain indexes of XYZ (mx3 matrix).
Simple example :
tri = delaunay(X,Y);
exportTriangulation2VTK('sampleExampleTri',[X Y Z],tri)
Note : If the triangulation doesn't have Z component (a plane), put the third column of XYZ with all zeros. Paraview only deals with 3D object.
David Gingras (2023). Export triangulation to Paraview (https://www.mathworks.com/matlabcentral/fileexchange/22602-export-triangulation-to-paraview), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform CompatibilityWindows macOS Linux
Inspired: vtkwrite : Exports various 2D/3D data to ParaView in VTK file format
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!
Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.