MATLAB: “index exceeds matrix dimensions”

error messageindexoderunge kutter

I can't figure out why it is showing me this, here are the lines of relevant code, thanks for any help you might have

Best Answer

The length of x vector is 3 and you defined y vector the same vay but at the line 21 when i=4, you try to reach y(4), which is invalid because you already defined that y has 3 elements at the line 11. Check it.
Related Question