I am modelling a 1 dof spring-mass-damper system with friction. As first attempt I modelled the friction according to the simple Coulomb model (figure A here http://article.sapub.org/image/10.5923.j.mechanics.20130301.04_006.gif) and it worked fine.Now I want to add the effect of the static friction when v = 0 m/s (figure C http://article.sapub.org/image/10.5923.j.mechanics.20130301.04_006.gif), but I cannot make it work. In fact I would expect to obtain something similar to the first model, but it is not so.The equations I modelled are:for the slipping case ($\dot{x}$ different from 0)$ m\ddot{x} + c\dot{x} + kx = -m\ddot{y} - \mu_{d} N $ if $\dot{x} > 0$$ m\ddot{x} + c\dot{x} + kx = -m\ddot{y} + \mu_{d} N $ if $\dot{x} < 0$for the sticking case ($\dot{x} = 0$) I have 3 equations:$ m\ddot{x} + c\dot{x} + kx = - m\ddot{y} + kx $ if $ |kx+m\ddot{y}| < \mu_{s} N$If $ |kx+m\ddot{y}| > \mu_{s} N$ then the equations are$ m\ddot{x} + c\dot{x} + kx = -m\ddot{y} -\mu_{s} N $ if $ kx+m\ddot{y} > 0$$ m\ddot{x} + c\dot{x} + kx = -m\ddot{y} +\mu_{s} N $ if $ kx+m\ddot{y} < 0$where $N$ is the normal force and $-m\ddot{y}$ represents the logarithmic sweep base excitation given as $\ddot{y} = A*\sin{(\phi(t))}$.So, the starting equation is chosen as follows% Initial conditionsq0 = [0;0];% Choose starting equationif q0(2) ~= 0     flag1 = 0;else    flag1 = 1;endThen, to switch from one equation to the other set I need events:function [value,isterminal,direction] = events(t,q)    value = [q(2),q(2),...]; % Find the times when velocity changes sign     isterminal = [1,1,1]; % Stop the integration when the event functions                         % are satisfied    direction = [1,-1,0]; end The first 2 terms in the value look for changes in the velocity direction, but now I need to tell Matlab to choose between one of the 3 equations of the case $\dot{x} = 0$. The third condition I would add isabs(k*q(1)+m*A*sin(2*pi*(60*f0/(R*log(2.))*(2.^(R/60*t)-1))))-mus*NBut then if I try to add the condition for the 2 remaining equations I get an error on input matrix dimension here[t,q,te,qe,ie] = ode45(odefun,tspan,q0(:,1),options);
ODE events to switch between 5 equations (friction model)
matlab;ode