Advertisement
Guest User

Untitled

a guest
Jan 28th, 2020
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.75 KB | None | 0 0
  1. clear;
  2. clc;
  3. % Declare symbolic variables
  4. syms x1 x2 x3 x4 Mc Jc u x_10 J g Rc
  5. f= [x3; x4; (-Mc*g*sin(x2)+Mc*x1*x4^2)/(Jc/Rc^2+Mc);
  6. (-2*Mc*x1*x3*x4-Mc*g*x1*cos(x2)+u)/(Mc*x1^2+J+Jc)];
  7. h = x1;
  8. %Compute Jacobian
  9. dfdx = jacobian(f, [x1 x2 x3 x4]);
  10. dfdu = jacobian (f, u);
  11. dhdx = jacobian(h, [x1 x2 x3 x4]);
  12. dhdu = jacobian(h, u);
  13. %Compute A B C and D
  14. A = subs( dfdx, [x1 x2 x3 x4 u], [x_10 0 0 0 Mc*g*x_10] )
  15. B = subs( dfdu, [x1 x2 x3 x4 u], [x_10 0 0 0 Mc*g*x_10] )
  16. C = subs( dhdx, [x1 x2 x3 x4 u], [x_10 0 0 0 Mc*g*x_10] )
  17. D= subs( dhdu, [x1 x2 x3 x4 u], [x_10 0 0 0 Mc*g*x_10] )
  18. A =
  19. [0, 0, 1, 0]
  20. [0, 0, 0, 1]
  21. [0, -(Mc*g)/(Mc + Jc/Rc^2), 0, 0]
  22. [ -(Mc*g)/(Mc*x_10^2 + J + Jc),0, 0, 0]
  23. B =
  24. 0
  25. 0
  26. 0
  27. 1/(Mc*x_10^2 + J + Jc)
  28. C =
  29. [ 1, 0, 0, 0]
  30. D =
  31. 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement