how to solve non linear differential equation with sign function

3 views (last 30 days)
I have to solve the equation of the motion of a rigid block subjected to a horizontal base excitation ag. The equation of the motion is:
a + nk*g*sign(v) = - ag
a=acceleration of the block, nk=friction coefficient, g=gravity acceleration, v=velocity of the block, ag=horizontal base excitation
I am trying to solve it by ODE45 solver but because of the sign function it doesn't work: I have wrong results. I would like to know how to solve this kind of equation on Matlab. Thank you so much!
FUNCTION:
function xdot = sliding(a,x)
n=size(a);
nk = 0.3; % friction coefficient
g = 9.810; % Gravitational constant in m/sec^2
for i=1:n(1)
xdot = [x(2);
-a(i,1)-nk*g];
end
SCRIPT:
a=0:0.1:4; %acceleration
t=0:0.1:4; %time
a=[a' t'];
x0 = [0; 0]; %initial condition
[t,x] = ode45('sliding',a(:,2),x0);
plot(t,a(:,1),'-');
xlabel('time'); ylabel('a(t)'); title('a (t)');
figure;
plot(t,x(:,1),'-'); xlabel('time'); ylabel('y_{1}(t)'); title('x (t)');
figure;
plot(t,x(:,2),'-'); xlabel('time'); ylabel('y_{2}(t)'); title('d x / dt (t)');

Accepted Answer

Star Strider
Star Strider on 25 Feb 2014
I knew I’d seen this problem before! See if this answer ( Is it possible to solve a nonlinear system with signum function using ODE45? ) applies to your problem.
  7 Comments
Star Strider
Star Strider on 28 Feb 2014
I thought we needed three functions of time:
  • position, x(t)
  • velocity, x’(t)
  • acceleration x”(t)
That makes a(t) = x”(t), correct? That is how I am used to thinking of problems like this. I think part of my problem is understanding the background of this problem.
I still do not understand ‘ ag: the acceleration of the ground. ’ I also do not understand why it is a vector.
I apologise, but I am still lost.
sara grossi
sara grossi on 28 Feb 2014
I apologize again for not being clear. I rephrase the problem:
The motion is initiated from rest once ag > 3.9. (if ag < 3.9 the body rests.)
Once sliding, the governing equation of motion may be expressed as x''(t) = -ag(t) - S(x'(t))*nk*g in which S(x'(t)) is defined through the signum function: S(x'(t))=1 if x'(t)>0, S(x'(t))=-1 if x'(t)<0 The motion continues until the relative velocity of the body equals zero: x'=0 At that time, the body momentarily comes to rest relative to the ground and ag > or < 3.9 is evaluated to determine if it remains at rest, or starts to slide again.
ag is the input that makes move the body. It is the external acceleration given by the ground at the base of the body. ag is a vector because it is time dependent ag(t). When my code will be ready I will give it different ag. Rigth now I am trying to solve for a linear ground acceleration.
x''(t) = acceleration of the body relative to the ground; x'(t) = velocity of the body relative to the ground; nk= friction coefficient; g=gravity acceleration.
So there are two acceleration: the acceleration of the ground ag(t) and the acceleration of the body x''(t). I need to solve the equation to have x'(t), x(t).
Thank you for your patience!

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!