Loop over perfect foresight with expactation error

Hi everyone,
I am trying to produce simulations for different values of predetermined shocks using perfect foresight with expectation error.

The model has two shocks: productivity (anticipated) and monetary shock (unanticipated).
I want to produce 30 simulations of this economy using different productivity shocks.

My code for that is in file simulation. But I get an error.
“if ~isempty(M_.endo_histval)”

Could someone please help me with this?

simple_model_single_firm.mod (7.5 KB)
simulate_test.m (980 Bytes)

simple_model_single_firm_steadystate.m (4.6 KB)

Try
simple_model_single_firm_steadystate.m (4.6 KB)
simple_model_single_firm.mod (7.5 KB)
simulate_test.m (993 Bytes)

The syntax should be

    oo_=perfect_foresight_with_expectation_errors_setup(M_, options_, oo_);
    oo_=perfect_foresight_with_expectation_errors_solver(M_, options_, oo_);

It keeps using the original shock from the mod file:( instead of the new shocks I feed it.

I think I fixed it by doing this (changing the order of lines)

    oo_=perfect_foresight_with_expectation_errors_setup(M_, options_, oo_);
    oo_.pfwee.shocks_info(2,:,:)=repmat(z_shock_vectors(i,:),1,1,100);
    oo_.exo_simul(:,2)=[0 z_shock_vectors(i,:) 0]';
    oo_=perfect_foresight_with_expectation_errors_solver(M_, options_, oo_);