Tuesday, January 10, 2017

Exercise to Simulate and Fit a Parabolic Shot.

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: