MATLAB: Writing differential equation for plot

second order differential equation

Can anyone help me how to write differential below equation for plot
d2x/dt2 = -sign(x + dx/dt)
I tried in below way and it is failing
ode = diff(x,t,2) == -sign(x + diff(x,t));

Best Answer

Try this
syms x(t)
d1x = diff(x);
d2x = diff(x,2);
ode = d2x == -sign(x + d1x);
cond = [x(0)==1 d1x(0)==0]
sol = dsolve(ode, cond)
This requires the Symbolic Math toolbox.