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: funDerivativeOp.m
    path of file: ./repos/2D_ALDIC/func
    
    the code of the file until where you have to start completion: function A = funDerivativeOp(M,N,h)
% FUNCTION A = funDerivativeOp(M,N,h)
% To generate a first order gradient operator {A} in the 2D case such that 
% {F} = {A}{U} where displacement vector U = [Ux_node1, Uy_node1, ... , Ux_nodeN, Uy_nodeN]',
% and deformation gradient F = [F11_node1, F21_node1, F12_node1, F22_node1, ... 
% ... , F11_nodeN, F21_nodeN, F12_nodeN, F22_nodeN]';
% ----------------------------------------------
%
%   INPUT: M,N   Mesh size in the x- and y-directions
%
%   OUTPUT: A    Finite difference operator
%
% ----------------------------------------------
% Author: Jin Yang.  
% Contact and support: jyang526@wisc.edu -or- aldicdvc@gmail.com
% Last time updated: 2018.03, 2020.12 
% ============================================== 


%% Initialization
DIM = 2;
A = sparse(DIM^2*M*N, DIM*M*N); 
sizeA = size(A); 

[XX,YY] = ndgrid(1:M,1:N); XX = XX(:); YY = YY(:);  
INDEXI = ones(2*DIM^2*M*N ,1); INDEXJ = INDEXI; INDEXVAL = INDEXI;



    
function A = funDerivativeOp(M,N,h)
% FUNCTION A = funDerivativeOp(M,N,h)
% To generate a first order gradient operator {A} in the 2D case such that 
% {F} = {A}{U} where displacement vector U = [Ux_node1, Uy_node1, ... , Ux_nodeN, Uy_nodeN]',
% and deformation gradient F = [F11_node1, F21_node1, F12_node1, F22_node1, ... 
% ... , F11_nodeN, F21_nodeN, F12_nodeN, F22_nodeN]';
% ----------------------------------------------
%
%   INPUT: M,N   Mesh size in the x- and y-directions
%
%   OUTPUT: A    Finite difference operator
%
% ----------------------------------------------
% Author: Jin Yang.  
% Contact and support: jyang526@wisc.edu -or- aldicdvc@gmail.com
% Last time updated: 2018.03, 2020.12 
% ============================================== 


%% Initialization
DIM = 2;
A = sparse(DIM^2*M*N, DIM*M*N); 
sizeA = size(A); 

[XX,YY] = ndgrid(1:M,1:N); XX = XX(:); YY = YY(:);  
INDEXI = ones(2*DIM^2*M*N ,1); INDEXJ = INDEXI; INDEXVAL = INDEXI;


%% ------ Inside assign values ------
for tempi = 1:M*N %%%%% Write into one for-loop in MATLAB instead of two for-loops
    tempx = XX(tempi); tempy = YY(tempi);  
%     for tempy = 1:N %%%%% 
%         for tempx = 1:M %%%%%
            
            % Determine BorderOrNot
            BorderOrNot = ones(1,DIM*2);  
            if tempy == 1, BorderOrNot(2) = 0; end