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: LMA.m
    path of file: ./repos/matlab_owc/matlab_codes
    
    the code of the file until where you have to start completion: 
function [ubrk, resnorm, residual] = LMA(ubrk)


global A breaks nbr1 ubrk_g
global xf yf W_i xblim
% Cecile Cabanes, 2019 (CC) changes of LMA.m & fdjacob.m to get similar convergence and
% solutions as lsqnonlin.m with the option 'levenberg-marquardt' (matlab
% optimization toolbox function)

nbr = length(ubrk);
%increment = 1e-10;
increment = 1e-2;    % CC: change initial value of increment
lambda =  diag(increment*ones(1,nbr));
e1=1;
max_cyc = 50;
cycles = 0;
done = false;
tolFun = 1e-6;
tolX = 1e-6;
while ~done
    %while e1>1e-15 % CC: new convergence criteria
    % Jacobian of least squares fit for P
    J = fdjacob(xf,yf,W_i,ubrk);
    residual = nlbpfun(ubrk);
    previous_residual = residual;
    cntr=0;
    while sum(previous_residual.^2)<=sum(residual.^2)
        % previous_residual = residual; % CC: only lambda is updated in the inner while loop
        N = J'*J + lambda;
        % deltaU = inv(N)*-J'*residual;
        deltaU = inv(N)*-J'*previous_residual; % CC: only lambda is updated in the inner while loop
        %Test Size of U's and distance between breaks
        new_ubrk = ubrk+deltaU';
        mb = length (new_ubrk);
    
function [ubrk, resnorm, residual] = LMA(ubrk)


global A breaks nbr1 ubrk_g
global xf yf W_i xblim
% Cecile Cabanes, 2019 (CC) changes of LMA.m & fdjacob.m to get similar convergence and
% solutions as lsqnonlin.m with the option 'levenberg-marquardt' (matlab
% optimization toolbox function)

nbr = length(ubrk);
%increment = 1e-10;
increment = 1e-2;    % CC: change initial value of increment
lambda =  diag(increment*ones(1,nbr));
e1=1;
max_cyc = 50;
cycles = 0;
done = false;
tolFun = 1e-6;
tolX = 1e-6;
while ~done
    %while e1>1e-15 % CC: new convergence criteria
    % Jacobian of least squares fit for P
    J = fdjacob(xf,yf,W_i,ubrk);
    residual = nlbpfun(ubrk);
    previous_residual = residual;
    cntr=0;
    while sum(previous_residual.^2)<=sum(residual.^2)
        % previous_residual = residual; % CC: only lambda is updated in the inner while loop
        N = J'*J + lambda;
        % deltaU = inv(N)*-J'*residual;
        deltaU = inv(N)*-J'*previous_residual; % CC: only lambda is updated in the inner while loop
        %Test Size of U's and distance between breaks
        new_ubrk = ubrk+deltaU';
        mb = length (new_ubrk);
        fnumer = zeros (size (new_ubrk) );
        fnumer(1) =  exp (new_ubrk(1));
        fdenom = 0.0;
        for i = 2:mb
            fnumer(i) = fnumer(i-1) + exp (new_ubrk(i));
        end