I assume that In your code line 28 it should be t(j) and t(j-1) instead of t(n) and t(n-1) respectively. Then your code at least is running.
For now, lets stick to that line. What is your intention here? You are extending an array by incrementing its last value. Try using the colon operator or the linspace command for array creation. For evenly spaced arrays they are way more powerful and comprehensible.