Exercise to Simulate and Fit a Parabolic Shot.

January 10, 2017

(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))

nh = seq(100, 1000, 10)

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


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

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

Get the example in:

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 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...

If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.


Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)