Thank you for your inputs. My concern was about calculating the cost to go map. I have discretized the state space and have 61 possible states in each stages and there are 20 such stages.
That roughly amounts to 61*61 values for one stage. I am overwhelmed by the amount of computations that this would mean and how best I could initialize a suitable array and index it for later use.
If you want the array initialized to zero you can call zeros(61, 61)
A few for loops should accomplish what you're after here. Depending how expenaive your cost function is to evaluate this doesn't sound very big at all. How many state and input dimensions do you have?
I have 3 states and two inputs. State 1 is [10:1:20], state 2 is [85:0.2:95] and state 3 is [1:1:12]. The two inputs are [0 1] and [-1 0].