Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2017
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. %Baseball_Model_1S To solve trajectory of baseball hit by bat
  2.  
  3. %Define initial conditions
  4. vel = 40; %launch speed m/s
  5. angle = 20; %launch angle in degrees
  6. vx = vel*cosd(angle);
  7. vy = vel*sind(angle);
  8.  
  9. ic = [0 vx 0 vy]; %initial conditions
  10.  
  11. %timesteps to evaluate model 10 secs
  12.  
  13. t = 0:0.05:5;
  14.  
  15. %ODE options to determine precision of model
  16.  
  17. options = odeset('RelTol',1e-4,'AbsTol',[1e-4,1e-4,1e-4,1e-4]');
  18. [T,Y] = ode45(@Baseball_Model_1F,t,ic,options); %runs the model
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25. %plotted results
  26. plot(Y(:,1),Y(:,3));
  27. xlabel('Horizontal Distance (m)')
  28. ylabel('Vertical Distance (m)')
  29. axis equal
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement