You've got a 4th order system (2 equations for x and y, each 2nd order --> 2 x 2 = 4), so your state vector will need to be 4 elements, not 2 elements like you currently have. Define the state vector as follows and then work from there:
y(1) = the x position
y(2) = the y position
y(3) = the x velocity
y(4) = the y velocity
Then in your derivative function you will have something like this:
dy=zeros(4,1);
dy(1) = y(3);
dy(2) = y(4);
dy(3) = _____;
dy(4) = _____;
Side Note: The DEQ in your Question is missing a minus sign (even though you do have it in your code)
Best Answer