# Exercise to Simulate and Fit a Parabolic Shot.

January 10, 2017
By

(This article was first published on Data R Value, and kindly contributed to R-bloggers)

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.

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)

lmr = lm(Distance ~ Height + I(Height^2))
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”)

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

Get the example in:
https://github.com/pakinja

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...