%This function allows for the linear interpolation of the value function at
%points between the grid points.
function[fxhat]=valuelin(k1,k2,vk1,vk2,ki,x)
global eta alpha beta delta
ck=ki^alpha+(1-delta)*ki-x; %consumption for the grid i capital
uk=utilchp4(ck,eta); %utility at choice x for kt+1
[fx]=lip(k1,k2,vk1,vk2,x); %linear interpolation of value function 
fxhat=uk+beta*fx; %linear interpolated value function