You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: savemsh.m
    path of file: ./repos/mesh2d/mesh-file
    
    the code of the file until where you have to start completion: function savemsh(name,mesh)
%SAVEMSH save a *.MSH file for JIGSAW.
%
%   SAVEMSH(NAME,MESH);
%
%   The following are optionally written to "NAME.MSH". Ent-
%   ities are written if they are present in MESH:
%
%   .IF. MESH.MSHID == 'EUCLIDEAN-MESH':
%   -----------------------------------
%
%   MESH.POINT.COORD - [NPxND+1] array of point coordinates,
%       where ND is the number of spatial dimenions.
%       COORD(K,ND+1) is an ID tag for the K-TH point.
%
%   MESH.POINT.POWER - [NPx 1] array of vertex "weights",
%       associated with the dual "power" tessellation.
%
%   MESH.EDGE2.INDEX - [N2x 3] array of indexing for EDGE-2
%       elements, where INDEX(K,1:2) is an array of
%       "point-indices" associated with the K-TH edge, and
%       INDEX(K,3) is an ID tag for the K-TH edge.
%
%   MESH.TRIA3.INDEX - [N3x 4] array of indexing for TRIA-3
%       elements, where INDEX(K,1:3) is an array of
%       "point-indices" associated with the K-TH tria, and
%       INDEX(K,4) is an ID tag for the K-TH tria.
%
%   MESH.QUAD4.INDEX - [N4x 5] array of indexing for QUAD-4
%       elements, where INDEX(K,1:4) is an array of
%       "point-indices" associated with the K-TH quad, and
%       INDEX(K,5) is an ID tag for the K-TH quad.
%
%   MESH.TRIA4.INDEX - [M4x 5] array of indexing for TRIA-4
%       elements, where INDEX(K,1:4) is an array of
%       "point-indices" associated with the K-TH tria, and
%       INDEX(K,5) is an ID tag for the K-TH tria.
%
%   MESH.HEXA8.INDEX - [M8x 9] array of indexing for HEXA-8
%       elements, where INDEX(K,1:8) is an array of
%       "point-indices" associated with the K-TH hexa, and
%       INDEX(K,9) is an ID tag for the K-TH hexa.
%
%   MESH.WEDG6.INDEX - [M6x 7] array of indexing for WEDG-6
%       elements, where INDEX(K,1:6) is an array of
%       "point-indices" associated with the K-TH wedg, and
%       INDEX(K,7) is an ID tag for the K-TH wedg.
%
%   MESH.PYRA5.INDEX - [M5x 6] array of indexing for PYRA-5
%       elements, where INDEX(K,1:5) is an array of
%       "point-indices" associated with the K-TH pyra, and
%       INDEX(K,6) is an ID tag for the K-TH pyra.
%
%   MESH.BOUND.INDEX - [NBx 3] array of "boundary" indexing
%       in the domain, indicating how elements in the
%       geometry are associated with various enclosed areas
%       /volumes, herein known as "parts". INDEX(:,1) is an
%       array of "part" ID's, INDEX(:,2) is an array of

    
function savemsh(name,mesh)
%SAVEMSH save a *.MSH file for JIGSAW.
%
%   SAVEMSH(NAME,MESH);
%
%   The following are optionally written to "NAME.MSH". Ent-
%   ities are written if they are present in MESH:
%
%   .IF. MESH.MSHID == 'EUCLIDEAN-MESH':
%   -----------------------------------
%
%   MESH.POINT.COORD - [NPxND+1] array of point coordinates,
%       where ND is the number of spatial dimenions.
%       COORD(K,ND+1) is an ID tag for the K-TH point.
%
%   MESH.POINT.POWER - [NPx 1] array of vertex "weights",
%       associated with the dual "power" tessellation.
%
%   MESH.EDGE2.INDEX - [N2x 3] array of indexing for EDGE-2
%       elements, where INDEX(K,1:2) is an array of
%       "point-indices" associated with the K-TH edge, and
%       INDEX(K,3) is an ID tag for the K-TH edge.
%
%   MESH.TRIA3.INDEX - [N3x 4] array of indexing for TRIA-3
%       elements, where INDEX(K,1:3) is an array of
%       "point-indices" associated with the K-TH tria, and
%       INDEX(K,4) is an ID tag for the K-TH tria.
%
%   MESH.QUAD4.INDEX - [N4x 5] array of indexing for QUAD-4
%       elements, where INDEX(K,1:4) is an array of
%       "point-indices" associated with the K-TH quad, and
%       INDEX(K,5) is an ID tag for the K-TH quad.
%
%   MESH.TRIA4.INDEX - [M4x 5] array of indexing for TRIA-4
%       elements, where INDEX(K,1:4) is an array of
%       "point-indices" associated with the K-TH tria, and
%       INDEX(K,5) is an ID tag for the K-TH tria.
%
%   MESH.HEXA8.INDEX - [M8x 9] array of indexing for HEXA-8
%       elements, where INDEX(K,1:8) is an array of
%       "point-indices" associated with the K-TH hexa, and
%       INDEX(K,9) is an ID tag for the K-TH hexa.
%
%   MESH.WEDG6.INDEX - [M6x 7] array of indexing for WEDG-6
%       elements, where INDEX(K,1:6) is an array of
%       "point-indices" associated with the K-TH wedg, and
%       INDEX(K,7) is an ID tag for the K-TH wedg.
%
%   MESH.PYRA5.INDEX - [M5x 6] array of indexing for PYRA-5
%       elements, where INDEX(K,1:5) is an array of
%       "point-indices" associated with the K-TH pyra, and
%       INDEX(K,6) is an ID tag for the K-TH pyra.
%
%   MESH.BOUND.INDEX - [NBx 3] array of "boundary" indexing
%       in the domain, indicating how elements in the
%       geometry are associated with various enclosed areas
%       /volumes, herein known as "parts". INDEX(:,1) is an
%       array of "part" ID's, INDEX(:,2) is an array of
%       element numbering and INDEX(:,3) is an array of
%       element "tags", describing which element "kind" is
%       numbered via INDEX(:,2). Element tags are defined
%       via a series of constants instantiated in LIBDATA.
%       In the default case, where BOUND is not specified,
%       all elements in the geometry are assumed to define
%       the boundaries of enclosed "parts".
%
%   MESH.VALUE - [NPxNV] array of "values" associated with
%       the vertices of the mesh. NV values are associated
%       with each vertex.
%
%   MESH.SLOPE - [NPx 1] array of "slopes" associated with
%       the vertices of the mesh. Slope values define the
%       gradient-limits ||dh/dx|| used by the Eikonal solver
%       MARCHE.
%
%   .IF. MESH.MSHID == 'ELLIPSOID-MESH':
%   -----------------------------------
%
%   MESH.RADII - [ 3x 1] array of principle ellipsoid radii.
%
%   Additionally, entities described in the 'EUCLIDEAN-MESH'
%   data-type are optionally written.
%
%   .IF. MESH.MSHID == 'EUCLIDEAN-GRID':
%   .OR. MESH.MSHID == 'ELLIPSOID-GRID':
%   -----------------------------------
%
%   MESH.POINT.COORD - [NDx1] cell array of grid coordinates
%       where ND is the number of spatial dimenions. Each
%       array COORD{ID} should be a vector of grid coord.'s,
%       increasing or decreasing monotonically.
%
%   MESH.VALUE - [NMxNV] array of "values" associated with
%       the vertices of the grid, where NM is the product of
%       the dimensions of the grid. NV values are associated
%       with each vertex.
%
%   MESH.SLOPE - [NMx 1] array of "slopes" associated with
%       the vertices of the grid, where NM is the product of
%       the dimensions of the grid. Slope values define the
%       gradient-limits ||dh/dx|| used by the Eikonal solver
%       MARCHE.
%
%   See also JIGSAW, LOADMSH
%

%-----------------------------------------------------------
%   Darren Engwirda
%   github.com/dengwirda/jigsaw-matlab
%   20-Aug-2019
%   darren.engwirda@columbia.edu
%-----------------------------------------------------------
%

   [ok] = certify(mesh);

    if (~ischar  (name))
        error('NAME must be a valid file-name!') ;
    end