You define T as a scalar
T = 1
but then in your for loop try to index out values from it like it is a vector
dV(i)=(QQ_mi(V(i-1),T(i-1))-QQ_pl(V(i-1),T(i-1)))*t(i)
You will therefore get this error message any time i>2 (since index is T(i-1)).
Just like you add values to V in each loop, you likely need to do something similar for T.