ODE45 takes a function, f(t,y), describing the differential equation.
You have a differential equation something like this
where k has one value if the spring moves in one direction (dy/dy < 0) and another value when the spring moves in the other direction - how you connect those forces at the points where the velocity is zero I do not know.
ODE45 takes functions describing first-order odes, so the way to implement equations of motions is to convert the second-order ODE to 2 coupled first-order odes. That way we get something like this:
function dydtdvdt = your_ode(t,y)
k_p = 12;
k_n = 10;
if y(2) > 0
a = -k_p * y(1);
a = -k_n * y(1);
dydtdvdt = [y(2);
Then you call ODE45 with this function the time-period of interest and the initial conditions (y(0) and v(0)), and then you get the numerical solution to your ODE. If you have a damper you'll have to add that force-term too.