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: evalcon.m
    path of file: ./repos/prima/matlab/interfaces/private
    
    the code of the file until where you have to start completion: function [cineq, ceq, succ] = evalcon(invoker, nonlcon, x, constrmax)
%EVALCON evaluates a constraint function `[cineq, ceq] = nonlcon(x)`.
% In particular, it uses a 'moderated extreme barrier' to cope with 'hidden constraints' or
% evaluation failures.

succ = true;

try
    [cineq, ceq] = nonlcon(x);
catch exception
    succ = false;
    cineq = NaN;
    ceq = NaN;
    wid = sprintf('%s:ConstraintFailure', invoker);
    if ~isempty(exception.identifier)
        wmsg = sprintf('%s: Constraint function fails with the following error:\n  %s: %s\n  Error occurred in %s, line %d', ...
            invoker,
    
function returns ceq =\n%s\nAny value that is not real or with an absolute value above constrmax = %g is replaced by constrmax.\nThe value of x is:\n%s\n', invoker, cstr, constrmax, xstr);
    warning(wid, '%s', wmsg);
    %warnings = [warnings, wmsg];  % We do not record this warning in the output.

    % Apply the moderated extreme barrier:
    ceq(~isreal(ceq) | ceq ~= ceq | ceq > constrmax) = constrmax;
    ceq(ceq < -constrmax) = -constrmax;
end

% This part is NOT an extreme barrier. We replace extremely negative values of
% cineq (which leads to no constraint violation) by -constrmax. Otherwise,
% NaN or Inf may occur in the interpolation models.
cineq(cineq < -constrmax) = -constrmax;

cineq = double(real(cineq(:))); % Some functions like 'asin' can return complex values even when it is not intend