# where x is a vector with its first entry x(1) corresponding to the position of a given mass and its second entry x(2) correpsonding to the velocity dxdt = @(t,x) [x(2); -x(2)-x(1)]; tLim = [0,10]; x0 = [0,1]; [tSol,xSol] = ode45(dxdt, tLim, x0); plot(tSol, xSol(:,1)); hold on plot(tSol, xSol(:,2));