how to solve a ODEs with heaviside function?
I am solving a ODEs with a heaviside funstion in it. since it will bring stiffness to the problems, so i use ODE15s and ODE23s. the former took a lot of time and the result is not what I want to some unknown reasons. and the latter can' t solve due to low accuracy inherently. below is my function, How can I solve this?
%function
function dx=Integrated_ode(t,x)t1=1100; t2=1200;FAI1=1+heaviside(t-t2)-heaviside(t-t1);FAI2=heaviside(t-t1)-heaviside(t-t2);dx=zeros(4,1); dx(1)=x(2); % x(1)=displacement;c
dx(2)=-2.1100e-04*cos(0.4438*t)-2*0.0045*x(2)-(1-1.0429)*x(1)-167.1087*x(1)^3-0.1606*x(3)+0.1014*x(4);dx(3)=x(2)-7.4957*x(3)+(-2.4162e+03*FAI2)*x(4);dx(4)=-x(2)+(-3.8247e+03*FAI2)*x(3)+(591.7674*FAI1)*x(4);
by the way, the ODEs without the heaviside can be solved by the ODE23s and ODE15s. so the equation is ok I think.
%
heaviside(sym(0));oldparam=sympref('HeavisideAtOrigin', 0);[T,z]=ode15s(@Integrated_ode,[0 3000],[0 0 0 0]);plot3(T,z(:,1),z(:,2),'b');
Best Answer