ODE45 not updating a variable of nonlinear 2nd order diff.eq system
Show older comments
Hello everyone, I was trying to solve a simple nonlinear system of diff.eqn (piece-wise linear) that involves coulomb friction. The problem I face is x(3) does not update after passing if condition... Although when i debug it, I can see that its varying accordingly... but at the end get a vector filled with a constant number(initial condition x3(0).) Could you please guide me how to cope with this issue???
function [dxdt]=func6(t,x)
C=10;
k=5;
kd=10;
F=25;
mu=0.5;
Nf=15;
m=1;
wn=sqrt(k/m);
w=wn;
fE=F*sin(w*t);
dxdt=zeros(size(x));
x1=x(1);
x2=x(2);
x3=x(3);
dxdt(1)=x(2);
%
nonlinear force calculation function
F_NL=kd*(x(1)-x(3));
if F_NL>=mu*Nf
F_NL=mu*Nf;
x(3)=x(1)-(mu*Nf)/kd;
end
if F_NL<=-mu*Nf
F_NL=-mu*Nf;
x(3)=x(1)+(mu*Nf)/kd;
end
dxdt(2)=1/m*(fE-F_NL-C*x(2)-k*x(1));
end
%%%and am using this script to run my ode calculations...
h=0.01;
tspan = 0:h:10;
initialvalues=[0 0 0];
[t,x]=ode23(@func6,tspan,initialvalues);
Accepted Answer
More Answers (1)
Res
on 11 Sep 2018
0 votes
Categories
Find more on Ordinary Differential Equations 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!