function dfdt=myfun(t,x)
dfdt = [...
x(2);
(1.5*((x(2))^2)*(cos(3*(x(1)))))-(((pi/2)^2) * ...
(sin((pi*t)/2)))-(20*((x(1))-(sin((pi*t)/2)))) - ...
((0.5*((x(2))^2)*abs(cos(3*(x(1)))))+0.1) * ...
sat(((x(2)-((pi/2)*cos((pi*t)/2))) + ...
(20*(x(1)-(sin((pi*t)/2)))))/0.1)-(((abs(sin(t)))+1) * ...
(cos(3*x(1)))*((x(2))^2))
];
sat
in this equation is defined as follows:
function f = sat(y)
if abs(y) <= 1
f = y;
else
f = sign(y);
end
I am solving it first as an ODE using ODE45 where I define the differential equations as a vector:
[t, x] = ode45(@myfun, [0 4], [0 pi/2])
This works fine. But when I try to solve the same set of equations using fde12
:
[T,Y] = FDE12(ALPHA,FDEFUN,T0,TFINAL,Y0,h)
Now I call it:
t0 = 0;
tfinal= 4 ;
h = 0.01;
x0 = [0 pi/2];
[t, x] = fde12(0.95, @myfun, t0,tfinal, x0,h);
(alpha
is the order of fractional differentiation, e.g., 0.95
)
it gives the following error:
Attempted to access x(2); index out of bounds because numel(x) = 1.