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/jigsaw-matlab
    
    the code of the file until where you have to start completion: function savemsh(name,mesh,varargin)
%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 I
    
function save_mesh_format(ffid,nver,mesh,kind)
%SAVE-MESH-FORMAT save mesh data in unstructured-mesh format

    switch (upper(kind))
    case 'EUCLIDEAN-MESH'
            fprintf( ...
        ffid,'MSHID=%u;EUCLIDEAN-MESH\n',nver) ;

    case 'ELLIPSOID-MESH'
            fprintf( ...
        ffid,'MSHID=%u;ELLIPSOID-MESH\n',nver) ;

    end

    npts = +0 ;

    if (isfield(mesh,'radii') && ...
            ~isempty(mesh.radii) )

    %------------------------------------ write "RADII" data

        if (~isnumeric(mesh.radii))
            error('Incorrect input types');
        end
        if (ndims(mesh.radii) ~= 2)
            error('Incorrect dimensions!');
        end
        if (numel(mesh.radii) ~= 3)
            mesh.radii = mesh.radii(1) * ones(+3,+1);
        end

        fprintf(ffid,'RADII=%f;%f;%f\n',mesh.radii');

    end

    if (isfield(mesh,'point') && ...
            isfield(mesh.point,'coord') && ...
                ~isempty(mesh.point.coord) )

    %------------------------------------ write "POINT" data

        if (~isnumeric(mesh.point.coord))
            error('Incorrect input type!');
        end
        if (ndims(mesh.point.coord) ~= 2)
            error('Incorrect dimensions!');
        end

        ndim = size(mesh.point.coord,2)-1 ;
        npts = size(mesh.point.coord,1)-0 ;
        fprintf(ffid,['NDIMS=%u','\n'],ndim);

        fprintf(ffid, ...
            ['POINT=%u','\n'],size(mesh.point.coord,1));

        if (isa(mesh.point.coord,'double'))
            vstr = sprintf('%%1.%ug;',+17);
        else
            vstr = sprintf('%%1.%ug;',+ 9);
        end