The correct method for dx(2) is method 2. You need to have values defined before they are used. Method 1 will give the wrong result (using a past value that happens to be defined) or generate an error (if the value isn't yet defined). There is no such thing as "forward looking for values" in MATLAB.
Maybe reorder your equations like this if you want to make your equations look more like what you are using:
dx(4)=x(1)+2*x(2);
dx(1)=x(2);
dx(2)=k*x(1)+c*x(2)+dx(4);
dx(3)=x(4);
Best Answer