I would like to solve this equation
That is a 2nd order differential equation for a single degree of freedom oscillator.
I am using ode45 but the problem is to compute the restoring force . If the current time is denoted as t and the time step as , one has Therefore, I need to store precedents variable states to compute and consequently to solve ODE. I read there is a possibility to use global variables and to have access to current time values utilized the option Output function. However, I'm not exactly sure how to use the Output function and, unfortunately, I didn't find any examples in which it was clear how to use it. Is there anyone that can share an example that suits me? I would like to specify I pass the interval of integration as a vector with two elements, namely the initial and final times.