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_FHorz_GulPesendorfer_nod_noz_e_raw.m
    path of file: ./repos/VFIToolkit-matlab/ValueFnIter/FHorz/ExoticPrefs/GulPesendorfer
    
    the code of the file until where you have to start completion: function  [V,Policy]=ValueFnIter_Case1_FHorz_GulPesendorfer_nod_noz_e_raw(n_a, n_e, N_j, a_grid, e_gridvals_J, pi_e_J, ReturnFn, TemptationFn, Parameters, DiscountFactorParamNames, ReturnFnParamNames, TemptationFnParamNames, vfoptions);
% Note: have no z variable, do have e variables

N_a=prod(n_a);
N_e=p
    
function parameters (in order)
        ReturnFnParamsVec=CreateVectorFromParams(Parameters, ReturnFnParamNames,jj);
        TemptationFnParamsVec=CreateVectorFromParams(Parameters, TemptationFnParamNames,jj);
        DiscountFactorParamsVec=CreateVectorFromParams(Parameters, DiscountFactorParamNames,jj);
        DiscountFactorParamsVec=prod(DiscountFactorParamsVec);


        VKronNext_j=V(:,:,:,jj+1);

        VKronNext_j=sum(VKronNext_j.*pi_e2_J(1,1,:,jj),3);

        for e2_c=1:N_e2
            e2_val=e2_gridvals_J(e2_c,:,jj);
            ReturnMatrix_e2=CreateReturnFnMatrix_Case1_Disc_Par2e(ReturnFn, 0, n_a, n_e1, special_n_e2, 0, a_grid, e1_gridvals_J(:,:,jj), e2_val, ReturnFnParamsVec); % Just treat e1 as z and e2 as e

            EV_e2=VKronNext_j.*pi_e1_prime;
            EV_e2(isnan(EV_e2))=0; %multilications of -Inf with 0 gives NaN, this replaces them with zeros (as the zeros come from the transition probabilites)
            EV_e2=sum(EV_e2,2); % sum over z', leaving a singular second dimension

            TemptationMatrix_e2=CreateReturnFnMatrix_Case1_Disc_Par2e(TemptationFn, 0, n_a, n_e1, special_n_e2, 0, a_grid, e1_gridvals_J(:,:,jj), e2_val, TemptationFnParamsVec); % Just treat e1 as z and e2 as e
            MostTempting_e2=max(TemptationMatrix_e2,[],1);
            entireRHS_e2=ReturnMatrix_e2+TemptationMatrix_e2-ones(N_a,1).*MostTempting_e2+DiscountFactorParamsVec*EV_e2; %.*ones(1,N_a,1);

            % Calc the max and it's index
            [Vtemp,maxindex]=max(entireRHS_e2,[],1);

            V(:,:,e2_c,jj)=shiftdim(Vtemp,1);
            Policy(:,:,e2_c,jj)=shiftdim(maxindex,1);
        end