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: model_2d_plane_stress.m
    path of file: ./repos/Isogeometric-Analysis/models/elastostatics
    
    the code of the file until where you have to start completion: %--------------------------------------------------------------------------
%  Author: Isaac J. Lee (ijlee2@ices.utexas.edu)
%  
%  
%  Summary:
%  
%  This routine solves the problem of 2D linear elasticity (plane stress)
%  for isotropic and homogeneous materials.
%  
%  
%  Instructions:
%  
%  Use the terminal to run the driver file with this command:
%  
%      ./matbg.sh driver_2d_plane_stress.m output
%  
%  Note that,
%  
%      path_to_assembly_directory is the directory to the global and patch
%          assembly files
%      path_to_results_directory is the directory to the results file
%  
%  
%  Output:
%  
%  1. Coefficients for the displacement fields (.mat file)
%--------------------------------------------------------------------------
function model_2d_plane_stress(path_to_assembly_directory, path_to_r
    
function model_2d_plane_stress(path_to_assembly_directory, path_to_results_directory)
    % Feedback for user
    fprintf('\n');
    fprintf('----------------------------------------------------------------\n');
    fprintf('----------------------------------------------------------------\n\n');
    fprintf('  2D linear elasticity (plane stress) for isotropic and homogeneous materials.\n\n');
    
    
    % Load the global assembly file
    load(sprintf('%sfile_assembly_global', path_to_assembly_directory), ...
         'numPatches', ...
         'numNodesBeforePatch', ...
         'numMatrixEntries', ...
         'numDOFs', ...
         'numDOFsPerNode', ...
         'GN_array', ...
         ...
         'material_thickness');
    
    % Load the BCs file
    load(sprintf('%sfile_bc', path_to_assembly_directory), ...
         'ID_array', ...
         'BCU_array', ...
         'BCF_array', ...
         'numUnknownDOFs');
    
    
    % Initialize the row, column, value arrays for the elasticity matrix
    temp = zeros(numMatrixEntries, 1);
    rows_for_K    = temp;
    columns_for_K = temp;
    values_for_K  = temp;
    lastIndex_for_K = 0;
    
    clear temp;
    
    % Initialize the solution and RHS vectors
    u = zeros(numDOFs, 1);
    f = zeros(numDOFs, 1);
    
    % Prescribe the known values
    u(BCU_array(:, 1)) = BCU_array(:, 2);
    f(BCF_array(:, 1)) = BCF_array(:, 2);
    
    % Indices of unknown displacements and unknown forces
    index_u = (1 : numUnknownDOFs)';
    index_f = ((numUnknownDOFs + 1) : numDOFs)';
    
    
    
    %----------------------------------------------------------------------
    % ---------------------------------------------------------------------
    %   Begin: Loop over patches (p)
    % ---------------------------------------------------------------------
    %----------------------------------------------------------------------
    for p = 1 : numPatches
        % Load the patch assembly file
        load(sprintf('%sfile_assembly_patch%d', path_to_assembly_directory, p), ...
             'description', ...
             'elementType', ...
             'material_E', ...
             'material_nu', ...
             'p1', ...
             'p2', ...
             'nodes', ...
             'numNodesPerElement', ...
             'numDOFsPerElement', ...
             'bezierExtractions1', ...
             'bezierExtractions2', ...
             'numElements1', ...
             'numElements2', ...
             'elementSizes1', ...
             'elementSizes2', ...
             'IEN_array', ...
             'numQuadraturePoints');
        
        fprintf('\n');
        fprintf('  Patch %d: %s\n', p, description);
        fprintf('    Degree of the %s basis functions: (%d, %d)\n', elementType, p1, p2);
        fprintf('    Number of elements in the parametric domain: (%d, %d)\n', numElements1, numElements2);
        
        switch (lower(elementType))
            case {'bspline', 'b-spline'}
                elementType = 0;
                
            case 'nurbs'
                elementType = 1;
                
        end