I am currently trying to create a while-loop which iterates the evolution of the capital stock until it converges on the n-th digit. As I am still quite new to Matlab I face a lot of problems. I would be very thankful for any kind of help.
Here is my code:
% Model parameters alpha = 1/3; % s = 0.2; % Investment rate delta = 0.2; % Depreciation rate n = 0.02; % Growth of labor force g = 0.01; % technological progress eps = 1; k(1,1) = 0.5; i=0; while eps >= 1.0e-5 t = t+1; k(1,t) = (1/((1+n)*(1+g)))*((s*k(1,t-1)^alpha+(1-delta)*k(1,t-1))); z = k(1,t); z1 = k(1,t+1); kdif = z1-z ; eps = max(abs(kdif)); i = i + 1; if i >= 300 break; end end