Loop in Value Iteration Unrecognized by MATLAB
1 view (last 30 days)
Show older comments
Laura Freitas
on 25 Oct 2021
Commented: Laura Freitas
on 26 Oct 2021
I am trying to solve a value iteration problem. I have a matrix, EV, with two columns which must be estimated seperately. However, my loop doesn't work and doesn't allow me to iterate past the initial guess value. Basically, nothing past comand "while" works. MATLAB doesn't return an error or anything, it just doesn't do anything.
%Algorithm
EV0 = zeros(90,2); %Guess initial value of 0.
EV0_0 = EV0(:,1); %Column where i =0.
EV0_1 = EV0(:,2); %Column where i=1.
V = log(exp(u_0 + beta*EV0_0) + exp(u_1 + beta*EV0_1));
EV1_1 = P1*V;
EV1_0 = P0*V;
EV1 = [EV1_0 EV1_1];
while abs(EV1 - EV0) > 0.01 % continue to iterate until convergence is achieved
EV0 = EV1;
EV0_0 = EV0(:,1); %Column where i =0.
EV0_1 = EV0(:,2); %Column where i=1.
V = log(exp(u_0 + beta*EV0_0) + exp(u_1 + beta*EV0_1));
EV1_1 = P1*V;
EV1_0 = P0*V;
EV1 = [EV1_0 EV1_1];
end
Any help to understand how exactly I can get the loop to work would be greatly appreciated!
2 Comments
Accepted Answer
More Answers (0)
See Also
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!