how to solve non linear differential equation with sign function
3 views (last 30 days)
Show older comments
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)');
0 Comments
Accepted Answer
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
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.
More Answers (0)
See Also
Categories
Find more on Assembly in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!