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: arFitsCluster.m
    path of file: ./repos/d2d/arFramework3/ClusterFunctions
    
    the code of the file until where you have to start completion: % arFitsCluster(ps, [log_fit_history, backup_save])
%
% fit sequence on MATLAB cluster
%
% ps:                           parameter values      
% log_fit_history               [false]
% backup_save                   [false]

function arFitsCluster(ps, log_fit_history, backup_save)

global ar

if(~exis
    
function %g', objective_functino_val);
        
        if(log_fit_history)
            name = ar2.config.optimizers{ar2.config.optimizer};
            if(ar2.config.optimizer==5)
                tmpnames = arNLS;
                name = [name '_' tmpnames{ar2.config.optimizerStep+1}];
            end
            
            fit_hist(j).hist = ar2.fit;
            fit_hist(j).optimizer = ar2.config.optimizer;
            if(ar2.config.optimizer==5)
                fit_hist(j).optimizerStep = ar2.config.optimizerStep;
            else
                fit_hist(j).optimizerStep = nan;
            end
            fit_hist(j).config = ar2.config.optim;
            fit_hist(j).name = [name '_' sprintf('run%i', j)];
            
            [~,imin] = min(ar2.fit.chi2_hist + ar2.fit.constr_hist);
            fit_hist(j).p = ar2.fit.p_hist(imin,:);
        end