User Tools

Site Tools


gibson:teaching:summer-2017:techcamp:computer-homerun

====== Differences ====== This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
gibson:teaching:summer-2017:techcamp:computer-homerun [2017/07/17 19:59]
gibson created
gibson:teaching:summer-2017:techcamp:computer-homerun [2017/07/18 07:27] (current)
gibson
Line 4: Line 4:
 The code on the other page is kind of unwieldy for tweaking the speed and angle of the ball. We can revise it to make it easier to try different values of $v$ and $\theta$. Let's wrap all the code in a function of those two variables and include a numerical test to see if the ball clears the outfield fence. ​ The code on the other page is kind of unwieldy for tweaking the speed and angle of the ball. We can revise it to make it easier to try different values of $v$ and $\theta$. Let's wrap all the code in a function of those two variables and include a numerical test to see if the ball clears the outfield fence. ​
  
-<​code>​+<​code ​matlab>
 function hitball(v, theta) function hitball(v, theta)
 +% simulate trajectory of a baseball hit with speed v (m/s) and angle (degrees)
 +% make a plot and determine if it clears the 17 ft outfield fence at 3
 +
   x = 0.0;      % horizontal position of home plate, meters   x = 0.0;      % horizontal position of home plate, meters
   y = 1.0;      % height of ball over strike zone   y = 1.0;      % height of ball over strike zone
Line 50: Line 53:
 </​code>​ </​code>​
  
-Now you can try different speeds $v$ and angles $\theta$ by just typing ​+Now you can try different speeds $v$ and angles $\theta$ by calling the ``hitball`` function at the Matlab prompt. For example, to compute the trajectory for $v=20$ and $\theta = 70^\circ$, type
  
 <code matlab> <code matlab>
gibson/teaching/summer-2017/techcamp/computer-homerun.1500346746.txt.gz · Last modified: 2017/07/17 19:59 by gibson