MATLAB: Index exceeds matrix dimensions Error for a for Loop

for loop

I am trying to create a for loop where with given initial values, I want to recalculate t, T, and S_dot each time, where the answer from each loop can then be stored:
dis_stp = 0.1.*Dc;
t(1) = 61;
T(1) = 10;
V = 2;
S_dot(1) = exp(((t(1)./sig)-uo)./a).*(T(1)^(-b./a))
t_step(1) = dis_stp/S_dot(1)
disp(1) = S_dot(1).*t_step(1)
for i = 2:50
t(i) = t(i-1)+K*((V*t_step(i-1))-(S_dot(i-1)*t_step(i-1)))
T(i) = (Dc/S_dot(i-1))+(T(i-1)-(Dc/S_dot(i-1)))*exp((-S_dot(i-1)*t_step(i-1))/Dc)
S_dot(i) = exp(((t(i-1)./sig)-uo)./a).*(T(i-1)^(-b./a))
end
A = [t T S_dot]'
When I do this, I get an error of
Index exceeds matrix dimensions. t(i) = t(i-1)+K*((V*t_step(i-1))-(S_dot(i-1)*t_step(i-1)))
and I cannot figure out what is wrong.
Any help would be GREATLY appreciated.
J

Best Answer

t_step(2) does not exist.