This code is a simulation of a sliding mode controller of a non-autonomous dynamic. When I use ArcTan
in input, I receive an error. ArcTan
is used instead of the Sign
function that is usually used in SMC controller for smoothness of dynamics. If Sign
is used instead of Arctan
a different error is recieved.
ClearAll[x1, x2, x3];
c = 5;
k = 1;
r[t_] := Evaluate[2];
rdot[t_] := Evaluate[D[r[t], t]];
r2dot[t_] := Evaluate[D[r[t], {t, 2}]];
u[t_] := 1/
b2[t]*(-(a21[t]*x1[t] + a22[t]*x2[t]) +
r2dot[t] -c (x3'[t] - rdot[t]) -
k*2/Pi*Arctan[((x3'[t] - rdot[t]) + c (x3[t] - r[t]))]);
a11[t_] := -0.4683*Exp[-0.03955*t] - 5.787*Exp[-2.308*t];
a12[t_] := (-1.248*10^(-8)*t^4 + 2.863*10^(-6)*t^3 - 0.0001976*t^2 +
1.004*t + 1.112)/(t + 1.115);
a13[t_] := -1.771*Exp[-3.312*t] - 0.3232*Exp[-0.2442*t]
a21[t_] :=
8.044*Sin[0.176*t + 0.8637] + 8.672*Sin[0.06238*t - 2.693] +
3.578*Sin[0.3067*t - 2.259] + 1.41*Sin[0.4156*t - 4.424];
a22[t_] :=
0.1411*Sin[0.04112*t - 2.51] + 0.03332*Sin[0.1928*t - 5.057] +
0.01927*Sin[0.329*t - 2.967] + 0.01594*Sin[0.4339*t - 4.503];
b1[t_] := -0.3851*Exp[-3.171*t] - 0.06556*Exp[-0.2131*t];
b2[t_] :=
1.295*Exp[-((t - 48.88)/6.474)] + 1.826*Exp[-((t - 6.799)/27.72)] +
1.283*Exp[-((t - 37.72)/13.11)];
sol = First[
NDSolve[{x1'[t] ==
a11[t]*x1[t] + a12[t]*x2[t] + a13[t]*x3[t] + b1[t]*u[t],
x2'[t] == a21[t]*x1[t] + a22[t]*x2[t] + b2[t]*u[t],
x3'[t] == x2[t], x1[0] == -2, x2[0] == 2, x3[0] == -4}, {x1, x2,
x3}, {t, 0, 1000}]];
Show[Plot[r[t], {t, 0, 50}, PlotRange -> {{0, 30}, {-5, 5}},
PlotStyle -> {Thick, Brown}],
Plot[Evaluate[{x1[t], x2[t], x3[t]} /. sol], {t, 0, 30},
PlotStyle -> {{Thick, Blue}, {Thick, Green, Dashed}, {Thick, Red,
Dotted}}, PlotRange -> {{0, 30}, {-5, 5}}]]
Error is:
NDSolve::ndsdtc: The time constraint of 1.` seconds was exceeded trying to solve for derivatives, so the system will be treated as a system of differential-algebraic equations. You can use Method->{"EquationSimplification"->"Solve"} to have the system solved as ordinary differential equations. >>