MATLAB: Vector from nested for loops

forloopmatrixnestedvector

From this code:
for n=0:30
for i=0:30
cost=subs(total_cost,{x,y},{n,i})
end
end
I need all the values of 'cost' to be stored in a matrix.
Any ideas?
Thanks.

Best Answer

cost(n+1,i+1) = subs(total_cost,{x,y},{n,i});