Advertisement
Guest User

Untitled

a guest
Jul 5th, 2015
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. ClearAll[x1, x2, x3];
  2. c = 5;
  3. k = 1;
  4.  
  5. r[t_] := Evaluate[2];
  6. rdot[t_] := Evaluate[D[r[t], t]];
  7. r2dot[t_] := Evaluate[D[r[t], {t, 2}]];
  8.  
  9. u[t_] := 1/
  10. b2[t]*(-(a21[t]*x1[t] + a22[t]*x2[t]) +
  11. r2dot[t] - c (x3'[t] - rdot[t]) -
  12. k*Sign[((x3'[t] - rdot[t]) + c (x3[t] - r[t]))]);
  13.  
  14. a11[t_] := -0.4683*Exp[-0.03955*t] - 5.787*Exp[-2.308*t];
  15. a12[t_] := (-1.248*10^(-8)*t^4 + 2.863*10^(-6)*t^3 - 0.0001976*t^2 +
  16. 1.004*t + 1.112)/(t + 1.115);
  17. a13[t_] := -1.771*Exp[-3.312*t] - 0.3232*Exp[-0.2442*t]
  18. a21[t_] :=
  19. 8.044*Sin[0.176*t + 0.8637] + 8.672*Sin[0.06238*t - 2.693] +
  20. 3.578*Sin[0.3067*t - 2.259] + 1.41*Sin[0.4156*t - 4.424];
  21. a22[t_] :=
  22. 0.1411*Sin[0.04112*t - 2.51] + 0.03332*Sin[0.1928*t - 5.057] +
  23. 0.01927*Sin[0.329*t - 2.967] + 0.01594*Sin[0.4339*t - 4.503];
  24. b1[t_] := -0.3851*Exp[-3.171*t] - 0.06556*Exp[-0.2131*t];
  25. b2[t_] :=
  26. 1.295*Exp[-((t - 48.88)/6.474)] + 1.826*Exp[-((t - 6.799)/27.72)] +
  27. 1.283*Exp[-((t - 37.72)/13.11)];
  28. sol =
  29. First[
  30. NDSolve[{
  31. x1'[t] == a11[t]*x1[t] + a12[t]*x2[t] + a13[t]*x3[t] + b1[t]*u[t],
  32. x2'[t] == a21[t]*x1[t] + a22[t]*x2[t] + b2[t]*u[t],
  33. x3'[t] == x2[t], x1[0] == -2, x2[0] == 2, x3[0] == -4},
  34. {x1, x2, x3}, {t, 0, 1000}]];
  35.  
  36. Show[
  37. Plot[r[t], {t, 0, 50},
  38. PlotRange -> {{0, 30}, {-5, 5}},
  39. PlotStyle -> {Thick, Brown}],
  40. Plot[Evaluate[{x1[t], x2[t], x3[t]} /. sol], {t, 0, 30},
  41. PlotStyle ->
  42. {{Thick, Blue}, {Thick, Green, Dashed}, {Thick, Red, Dotted}},
  43. PlotRange -> {{0, 30}, {-5, 5}}]]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement