Skip to main content
added 6 characters in body
Source Link
Dr. belisarius
  • 116.2k
  • 13
  • 205
  • 456

Rewrite the following parts of your code in order to eliminate x2:

u[t_] := 1/ b2[t]*(-(a21[t]*x1[t] + a22[t]*x3'[t]) + r2dot[t] - 
          c (x3'[t] - rdot[t]) -  k*Sign[((x3'[t] - rdot[t]) + c (x3[t] - r[t]))]);

sol = First[NDSolve[{
     x1'[t] == == a11[t]*x1[t] + a12[t]*x3'[t] + a13[t]*x3[t] + b1[t]*u[t], 
     x3''[t] == a21[t]*x1[t] + a22[t]*x3'[t] +                b2[t]*u[t],
     x1[0]   == -2,
     x3'[0]  == 2,
     x3[0]   == -4},
    {x1, x2x3}, {t, 0, 1000}} ]];

Show[Plot[r[t], {t, 0, 50}, PlotRange -> {{0, 30}, {-5, 5}}, 
          PlotStyle -> {Thick, Brown}], 
    Plot[Evaluate[{x1[t], x3[t]} /. sol], {t, 0, 30}, 
          PlotStyle -> {{Thick, Blue}, {Thick, Green, Dashed}},
          PlotRange -> {{0, 30}, {-5, 5}}]]

Mathematica graphics

Rewrite the following parts of your code to eliminate x2:

u[t_] := 1/ b2[t]*(-(a21[t]*x1[t] + a22[t]*x3'[t]) + r2dot[t] - 
          c (x3'[t] - rdot[t]) -  k*Sign[((x3'[t] - rdot[t]) + c (x3[t] - r[t]))]);

sol = First[NDSolve[{
     x1'[t] ==  a11[t]*x1[t] + a12[t]*x3'[t] + a13[t]*x3[t] + b1[t]*u[t], 
     x3''[t] == a21[t]*x1[t] + a22[t]*x3'[t] + b2[t]*u[t],
     x1[0] == -2,
     x3'[0] == 2,
     x3[0] == -4},
    {x1, x2}, {t, 0, 1000}} ]];

Show[Plot[r[t], {t, 0, 50}, PlotRange -> {{0, 30}, {-5, 5}}, 
          PlotStyle -> {Thick, Brown}], 
    Plot[Evaluate[{x1[t], x3[t]} /. sol], {t, 0, 30}, 
          PlotStyle -> {{Thick, Blue}, {Thick, Green, Dashed}},
          PlotRange -> {{0, 30}, {-5, 5}}]]

Mathematica graphics

Rewrite the following parts of your code in order to eliminate x2:

u[t_] := 1/ b2[t]*(-(a21[t]*x1[t] + a22[t]*x3'[t]) + r2dot[t] - 
          c (x3'[t] - rdot[t]) -  k*Sign[((x3'[t] - rdot[t]) + c (x3[t] - r[t]))]);

sol = First[NDSolve[{
     x1'[t]  == a11[t]*x1[t] + a12[t]*x3'[t] + a13[t]*x3[t] + b1[t]*u[t], 
     x3''[t] == a21[t]*x1[t] + a22[t]*x3'[t] +                b2[t]*u[t],
     x1[0]   == -2,
     x3'[0]  == 2,
     x3[0]   == -4},
    {x1, x3}, {t, 0, 1000}} ]];

Show[Plot[r[t], {t, 0, 50}, PlotRange -> {{0, 30}, {-5, 5}}, 
          PlotStyle -> {Thick, Brown}], 
    Plot[Evaluate[{x1[t], x3[t]} /. sol], {t, 0, 30}, 
          PlotStyle -> {{Thick, Blue}, {Thick, Green, Dashed}},
          PlotRange -> {{0, 30}, {-5, 5}}]]

Mathematica graphics

Source Link
Dr. belisarius
  • 116.2k
  • 13
  • 205
  • 456

Rewrite the following parts of your code to eliminate x2:

u[t_] := 1/ b2[t]*(-(a21[t]*x1[t] + a22[t]*x3'[t]) + r2dot[t] - 
          c (x3'[t] - rdot[t]) -  k*Sign[((x3'[t] - rdot[t]) + c (x3[t] - r[t]))]);

sol = First[NDSolve[{
     x1'[t] ==  a11[t]*x1[t] + a12[t]*x3'[t] + a13[t]*x3[t] + b1[t]*u[t], 
     x3''[t] == a21[t]*x1[t] + a22[t]*x3'[t] + b2[t]*u[t],
     x1[0] == -2,
     x3'[0] == 2,
     x3[0] == -4},
    {x1, x2}, {t, 0, 1000}} ]];

Show[Plot[r[t], {t, 0, 50}, PlotRange -> {{0, 30}, {-5, 5}}, 
          PlotStyle -> {Thick, Brown}], 
    Plot[Evaluate[{x1[t], x3[t]} /. sol], {t, 0, 30}, 
          PlotStyle -> {{Thick, Blue}, {Thick, Green, Dashed}},
          PlotRange -> {{0, 30}, {-5, 5}}]]

Mathematica graphics