A generic dynamic programming Matlab function
Dynamic Programming