Bellman equation with recursive function
Mostra commenti meno recenti
Hello,
I have a Bellman equation for which I have constructed a code with the help of loops, that calculates for me the optimal expected value:
function [V] = Bellmanneu(C,R1,R2,T,P1,P2,P0)
r = [R1 R2]
for t=(T+1):-1:1
for c=1:1:C+1
if c<=1
V(c,t) = 0
elseif t==T+1
V(c,t) = 0
else
V(c,t) = P1 * (r(1) + V(c-1,t+1)) + P2 * (r(2) + V(c-1,t+1)) + P0 * V(c,t+1)
end
end
end
end
Basically, I want to delete the first two for-loops and instead compute a recursive function that calls itself until t equals 1.
Can anyone help me out, at least with the first few steps that need to be taken?
Any help is much appreciated!
2 Commenti
Star Strider
il 19 Gen 2019
What are typical inputs to your function?
Amit Kumar
il 19 Gen 2019
Risposte (1)
Amit Kumar
il 23 Gen 2019
Categorie
Scopri di più su Automated Driving Toolbox in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!