# Exercise to Simulate and Fit a Parabolic Shot.

[This article was first published on

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

In this exercise we assume that we obtained the measurements of the height and the distance of the movement of a projectile by means of an experiment.**Data R Value**, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

We define the vectors “Height” and “Distance” that have our physical measurements.

We fit a second-order model “lmr”.

We defined a scale of heights “nh” to evaluate the motion equation.

With the coefficients of the adjusted model we define the motion equation “fit” and finally we plot.

**Height = c(100, 200, 300, 450, 600, 800, 1000)**

Distance = c(253, 337, 395, 451, 495, 535, 576)

Distance = c(253, 337, 395, 451, 495, 535, 576)

**lmr = lm(Distance ~ Height + I(Height^2))**

lmr

lmr

**nh = seq(100, 1000, 10)**

**fit = lmr$coefficients[1]+ lmr$coefficients[2]*nh +**

**lmr$coefficients[3]*nh^2**

**fit**

plot(Height, Distance, col = “red”, main=”Parabolic Shot Experiment”)

plot(Height, Distance, col = “red”, main=”Parabolic Shot Experiment”)

**lines(nh, fit, lty=1, col = “blue”)**

Get the example in:

https://github.com/pakinja

To

**leave a comment**for the author, please follow the link and comment on their blog:**Data R Value**.R-bloggers.com offers

**daily e-mail updates**about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.