%Parameters and Discretization of State-Space alf=.5; bet=.99; P=[.45 .55; %Markov Transition Matrix .35 .65]; k=[.05;.1;.15;.2;.25;.3]; %Capital Choce Set (with 6 discrete states) a=[1;1.5]; %Productivity States %Utility Matrices R1=[];R2=[]; for i=1:6 for j=1:6 if a(1)*(k(i)^alf)-k(j)>0 R1(i,j)=log((a(1)*(k(i)^alf))-k(j)); %Logarithmic Utility else R1(i,j)=-inf; %Weeding out the choices implying non-positive consumption end if a(2)*(k(i)^alf)-k(j)>0 R2(i,j)=log((a(2)*(k(i)^alf))-k(j)); else R2(i,j)=-inf; end end end %Value Function Iteration v1=ones(6,1);v2=ones(6,1); %Initial guesses for the value vector vn=1;vnt=0; while norm(vn-vnt)>10^(-8) vnt=[v1' v2']; [tv1,ind1]=max((R1+(bet*P(1,1)*ones(6,1)*v1')+(bet*P(1,2)*ones(6,1)*v2'))'); [tv2,ind2]=max((R2+(bet*P(2,1)*ones(6,1)*v1')+(bet*P(2,2)*ones(6,1)*v2'))'); v1=tv1';v2=tv2'; vn=[v1' v2']; end