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: stepz.m
    path of file: ./repos/malini/Codes/FC_EC_calculation code/DynamicFC/jplv7/optimize
    
    the code of the file until where you have to start completion: function alpha=step(b,infoz,stat,varargin)
% PURPOSE: Determine step size in NUMZ package
%-----------------------------------------------------------------
% USAGE: alpha=step(b,infoz,stat,varargin)
%  Where

    
function alpha=step(b,infoz,stat,varargin)
% PURPOSE: Determine step size in NUMZ package
%-----------------------------------------------------------------
% USAGE: alpha=step(b,infoz,stat,varargin)
%  Where
%  b         vector of model parameters
%  infoz     structure variable with settings for MINZ0
%  stat      structure variable with minimization status
%  varargin  Variable list of arguments passed to func
%
% RETURNS:   alpha     scalar step size
%-----------------------------------------------------------------
% REFERENCES:  Numerical Recipes in FORTRAN  (LNSRCH, p. 378)
%-----------------------------------------------------------------

% written by:
% Mike Cliff,  UNC Finance  mcliff@unc.edu
% CREATED:  1/24/99


%=================================================================
%  INITIALIZATIONS
%=================================================================

direc = stat.direc;
alf=infoz.ftol;
fold = stat.f;
maxalpha = 10;
alpha=1;
tmpalpha=1;
go=1;
lvar = length(varargin);
func = fcnchk(infoz.func,lvar);

% I don't use this step from  Num. Recipes; it causes trouble
%sumx = sqrt(direc'*direc)
%if sumx > maxalpha
%  direc = direc*maxalpha/sumx
%end