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: surfdiffuse.m
    path of file: ./repos/fieldtrip/external/iso2mesh
    
    the code of the file until where you have to start completion: function valnew=surfdiffuse(node,tri,val,ddt,iter,type1,opt)
%
% valnew=surfdiffuse(node,tri,val,ddt,iter,type1,opt)
%

    
function valnew=surfdiffuse(node,tri,val,ddt,iter,type1,opt)
%
% valnew=surfdiffuse(node,tri,val,ddt,iter,type1,opt)
%
% apply a smoothing/diffusion process on a surface
%
% author: Qianqian Fang, <q.fang at neu.edu>
%
% input:
%     node: list of nodes of the surface mesh
%     tri: triangular element list of the surface
%     val: vector, scalar value for each node
%     ddt: diffusion coefficient multiplied by delta t
%     iter: iterations for applying the smoothing
%     type1: indices of the nodes which will not be updated
%     opt: method, 'grad' for gradient based, and 'simple' for simple average
%
% output:
%     valnew: nodal value vector after the smoothing
%
% -- this function is part of iso2mesh toolbox (http://iso2mesh.sf.net)
%

if(iscell(tri))
	conn=tri;
else
	conn=meshconn(tri,size(node,1));
end