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: ValueFnIter_Case1_EndoVFI.m
    path of file: ./repos/VFIToolkit-matlab/ValueFnIter/InfHorz/EndogenousVFI
    
    the code of the file until where you have to start completion: function    [VKron,Policy]=ValueFnIter_Case1_EndoVFI(V0,n_d,n_a,n_z,d_grid,a_grid,z_grid,pi_z,ReturnFn,ReturnFnParamsVec,Disco
    
function is independent of time creating it once and
    % then using it every iteration is good for speed, but it does use a
    % lot of memory.
    
    if vfoptions.verbose==1
        disp('Creating return fn matrix')
        tic;
        if vfoptions.returnmatrix==0
            fprintf('NOTE: When using CPU you can speed things up by giving return fn as a matrix; see vfoptions.returnmatrix=1 in VFI Toolkit documentation. \n')
        end
    end
    
    if isfield(vfoptions,'statedependentparams')
        if vfoptions.returnmatrix==2 % GPU
            if n_SDP==3
                ReturnMatrix=CreateReturnFnMatrix_Case1_Disc_Par2_SDP(ReturnFn, n_d, n_a, n_z, d_grid, a_grid, z_grid, ReturnFnParamsVec,SDP1,SDP2,SDP3);
            elseif n_SDP==2
                ReturnMatrix=CreateReturnFnMatrix_Case1_Disc_Par2_SDP(ReturnFn, n_d, n_a, n_z, d_grid, a_grid, z_grid, ReturnFnParamsVec,SDP1,SDP2);
            elseif n_SDP==1
                ReturnMatrix=CreateReturnFnMatrix_Case1_Disc_Par2_SDP(ReturnFn, n_d, n_a, n_z, d_grid, a_grid, z_grid, ReturnFnParamsVec,SDP1);
            end