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: gridsurf.m
    path of file: ./repos/iso2mesh
    
    the code of the file until where you have to start completion: function [no,fc]=gridsurf(x,y,z, varargin)
%
% [no,fc]=gridsurf(x,y,z)
%    or
% [no,fc]=gridsurf(x,y,z, opt)
% [no,fc]=gridsurf(x,y,z, 'param1', value1, 'param2', value2, ...)
%
% convert a grid-shaped surface (used as input for surf) to a quad or triangular mesh
%

    
function [no,fc]=gridsurf(x,y,z, varargin)
%
% [no,fc]=gridsurf(x,y,z)
%    or
% [no,fc]=gridsurf(x,y,z, opt)
% [no,fc]=gridsurf(x,y,z, 'param1', value1, 'param2', value2, ...)
%
% convert a grid-shaped surface (used as input for surf) to a quad or triangular mesh
%
% author: Qianqian Fang, <q.fang at neu.edu>
%
% input:
%   x,y,z: parameter used as the input for surf()/mesh()
%   : a surface mesh triangle list (ne x 3)
%   opt: a list of optional parameters, currently surfacenorm supports:
%        'Type': [3|4|int] if set to 3 (default), output triangular mesh; if set to 4,
%                output a quad mesh where fc is an Nx4 array; otherwise,
%                output a quad mesh where fc is a cell array
%        'Nodup': [0|1] if set to 0 (default), no duplicated nodes in x/y/z are removed;
%                if set to 1, duplicated nodes are removed
%
% output:
%   no: output surface node coordinates
%   fc: output surface connections - if 'type' set to 3 or 4, fc is a numerical array,
%       otherwise, fc is a cell array with each element containing 4 integers
%
% -- this function is part of iso2mesh toolbox (http://iso2mesh.sf.net)
%

opt=varargin2struct(varargin{:});

s=size(x);
if(~all(s==size(y) & s==size(z)))
    error('x/y/z must be a 2D array of the same size');
end