I have a nonlinear-ODE of the second order with trigonometric functions such that I cannot formulate it depending of the second derivation. For example:
ay'' + b arctan(y'') + cy' + dy=0
y'(0)=0, y''(0)=0
Without existence of a term like arctan(y'') I could write my ode function like
function output=myodefunc(u,t){
y(1)=u(2);
y(2)=(-c*u(2)-d*u(1))/m;
output=y';
}
Unfortunately the nonlinear term of the second order (=> b*arctan(y'') ) makes me unable to write the ode in dependence of y'' .
Is there any way to solve such a trigonometric ode numerically in Matlab?
One can evaluate the y'' with a nonlinear solver (fsolve), within the ode function:
function output=myodefunc(u,t){
y(1)=u(2);
x0=0;
x=fsolve('a*x + b*atan(x) + c*u(2) + d*u(1)',x0);
y(2)=x;
output=y';
}