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: gradientTerm1D.m
    path of file: ./repos/FVTool/Calculus
    
    the code of the file until where you have to start completion: function faceGrad = gradientTerm1D(phi)
% this function calculates the gradient of a variable in x direction
% it checks for the availability of the ghost variables and use them, otherwise
% estimate them, assuming a zero gradient on the boundaries

    
function faceGrad = gradientTerm1D(phi)
% this function calculates the gradient of a variable in x direction
% it checks for the availability of the ghost variables and use them, otherwise
% estimate them, assuming a zero gradient on the boundaries
%
% SYNOPSIS:
%   faceGrad = gradientTerm1D(phi)
%
% PARAMETERS:
%
%
% RETURNS:
%
%
% EXAMPLE:
%
% SEE ALSO:
%


% check the size of the variable and the mesh dimension
Nx = phi.domain.dims(1);
DX = phi.domain.cellsize.x;
dx = 0.5*(DX(1:end