heidi - try using the MATLAB debugger to step through your code to determine what is going on. Note the following code T = 5;
X = zeros(T+1,1)
X(1) = 10;
iter=0
while (abs(X(T+1)) > TOL);
What is T supposed to represent? The maximum number of iterations or something else? Should you increment it on each iteration of the while loop? See how X is a 6x1 array of zeros except for the first element which is 10. Then, in the condition for the loop, you are accessing the sixth element (since T is five) of X which is zero...which is less than TOL and so you never enter the loop.
If X is supposed to represent all of the outputs on each iteration of the loop, then you probably want to initialize T to be one and then increment on each iteration and setting X(T) to be some value...but that will conflict with this code
for i = 1:T-1;
X(i+2,1) = A * (1 + ALPHA * BETA)* (X(i+1,1))^ALPHA + (1-DELTA) * (1 + BETA) * X(i+1,1)...
- BETA * (A * (X(i,1))^ALPHA + (1 - DELTA) * X(i,1)) * (A * ALPHA * X(i+1,1)^(ALPHA - 1) + (1 - DELTA));
end;
Perhaps this the shooting part of the algorithm (which I don't understand). Please use the debugger or add some comments to your code which describe what is being attempted.
Best Answer