Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- % starting values
- Xo = 0
- Yo = 0
- Vo = 100
- Oo = 2
- % time (integrate) span
- To = 0
- Tf = 1
- % constants
- g = 10
- % functions definition (divided by semicolon)
- f = @(t,a) [a(3)*sin(a(4)); a(3)*cos(a(4)); -g*sin(a(4)); -g*cos(a(4))/a(3)];
- % increasing accurasy
- options = odeset('RelTol',1e-1,'AbsTol',[1e-4 1e-4 1e-4]);
- % solving system by Runge–Kutta some class
- [t, ft] = ode45(f, [To, Tf], [Xo Yo Vo Oo], options);
- % plotting
- figure
- plot(t, ft(:,1), '-', t, ft(:,2), '-.', t, ft(:,3), '.', t, ft(:,4), '--')
- plot(ft(:,1), ft(:,2))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement