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: saveasc.m
    path of file: ./repos/fieldtrip/external/iso2mesh
    
    the code of the file until where you have to start completion: function saveasc(v,f,fname)
%
% saveasc(v,f,fname)
%
% save a surface mesh to FreeSurfer ASC mesh format
%
% author: Qianqian Fang, <q.fang at neu.edu>
% date: 2009/04/02

    
function saveasc(v,f,fname)
%
% saveasc(v,f,fname)
%
% save a surface mesh to FreeSurfer ASC mesh format
%
% author: Qianqian Fang, <q.fang at neu.edu>
% date: 2009/04/02
%
% input:
%      v: input, surface node list, dimension (nn,3)
%      f: input, surface face element list, dimension (be,3)
%      fname: output file name
%
% -- this function is part of iso2mesh toolbox (http://iso2mesh.sf.net)
%

fid=fopen(fname,'wt');
if(fid==-1)
    error('You do not have permission to save mesh files.');
end