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: tesgrid.m
    path of file: ./repos/GIBBON/lib
    
    the code of the file until where you have to start completion: function [E,V]=tesgrid(varargin)

% function [E,V]=tesgrid(xrange,yrange,zrange)
%-------------------------------------------------------------------------
% This function generates a gridded mesh and outputs a tesselation for that
% mesh. The input is similar to that of the |ndgrid| function in that a
% desired range for the x, y, and z coordinates is given. The output
% consists of the mesh simplices. For 2D input only the x and y ranges are
% specified and the output consists of quadrilateral faces and vertices of
% a 2D mesh. For 3D input the z coordinate range is also specified and the
% output consists of hexahedral elements and vertices. 
% 
%
% Kevin Mattheus Moerman
% gibbon.toolbox@gmail.com
% 
% Change log:
% 2018/17/08 Created
%-------------------------------------------------------------------------

%% Parse input

switch nargin
    case 1 %Assume homogenous 2D
        xrange=varargin{1};
        yrange=varargin{1};
        zrange=[];
    case 2 %2D
        xrange=varargin{1};

    
function [E,V]=tesgrid(varargin)

% function [E,V]=tesgrid(xrange,yrange,zrange)
%-------------------------------------------------------------------------
% This function generates a gridded mesh and outputs a tesselation for that
% mesh. The input is similar to that of the |ndgrid| function in that a
% desired range for the x, y, and z coordinates is given. The output
% consists of the mesh simplices. For 2D input only the x and y ranges are
% specified and the output consists of quadrilateral faces and vertices of
% a 2D mesh. For 3D input the z coordinate range is also specified and the
% output consists of hexahedral elements and vertices. 
% 
%
% Kevin Mattheus Moerman
% gibbon.toolbox@gmail.com
% 
% Change log:
% 2018/17/08 Created
%-------------------------------------------------------------------------

%% Parse input

switch nargin
    case 1 %Assume homogenous 2D
        xrange=varargin{1};
        yrange=varargin{1};
        zrange=[];
    case 2 %2D
        xrange=varargin{1};
        yrange=varargin{2};
        zrange=[];
    case 3 %3D
        xrange=varargin{1};
        yrange=varargin{2};
        zrange=varargin{3};
end