function output = myfunction(Knew)

% this function sets the initial value of the state variable K
% and calls Dynare to solve a perfect foresight solution starting from K


global M_ options_ oo_
% need this so that Dynare results can be used


%% Initial values for dynare
% This is the initial value used in Dynare 
save('parameter.mat', 'Knew');

% calls dynare
dynare rbc0.mod

%% Output
% Dynare perfect_foresight_solver solve the path of endogenous variables
% and I only need the value of the following 2 jump variables in period 1
C1 = oo_.endo_simul(find(strcmp('c',M_.endo_names)),1);
N1 = oo_.endo_simul(find(strcmp('n',M_.endo_names)),1);
output = [C1, N1];

