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: FGD.m
    path of file: ./repos/lrslibrary/algorithms/nmf/LNMF
    
    the code of the file until where you have to start completion: function [H2,Z2,sLen2,iter]=FGD(V,W,H,Z,tol)

% Fast gradient descent (FGD) with Newton method for NNLS
% Copyright 2010-2012 by Naiyang Guan and Dacheng Tao
% Arguments:
%     sLen: step length

% Calculate scaled negative gradient at W
n=size(V,2);
G=H.*(W'*(V./Z))./(sum(W)'*ones(1,n))-H;
Z1=W*G;
d=sum(sum(Z1));
C=Z./Z1;


    
function [H2,Z2,sLen2,iter]=FGD(V,W,H,Z,tol)

% Fast gradient descent (FGD) with Newton method for NNLS
% Copyright 2010-2012 by Naiyang Guan and Dacheng Tao
% Arguments:
%     sLen: step length

% Calculate scaled negative gradient at W
n=size(V,2);
G=H.*(W'*(V./Z))./(sum(W)'*ones(1,n))-H;
Z1=W*G;
d=sum(sum(Z1));
C=Z./Z1;

% Newton method
sLen=1;
for iter=1:20
    [sum1,sum2]=SumC1(V,C,sLen);
    sLen1=sLen-(d-sum1)/sum2;
    if abs(sLen1-sLen)<tol
        break;
    else
        sLen=sLen1;
    end