Advertisement
Deerenaros

some piece of shit

Mar 15th, 2017
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.54 KB | None | 0 0
  1. % starting values
  2. Xo = 0
  3. Yo = 0
  4. Vo = 100
  5. Oo = 2
  6.  
  7. % time (integrate) span
  8. To = 0
  9. Tf = 1
  10.  
  11. % constants
  12. g = 10
  13.  
  14. % functions definition (divided by semicolon)
  15. f = @(t,a) [a(3)*sin(a(4)); a(3)*cos(a(4)); -g*sin(a(4)); -g*cos(a(4))/a(3)];
  16. % increasing accurasy
  17. options = odeset('RelTol',1e-1,'AbsTol',[1e-4 1e-4 1e-4]);
  18. % solving system by Runge–Kutta some class
  19. [t, ft] = ode45(f, [To, Tf], [Xo Yo Vo Oo], options);
  20.  
  21. % plotting
  22. figure
  23. plot(t, ft(:,1), '-', t, ft(:,2), '-.', t, ft(:,3), '.', t, ft(:,4), '--')
  24. plot(ft(:,1), ft(:,2))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement