Collects and plots the quadratic curve for upper and lower surfaces of the lens.
1 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | ##---- Should be DIRECTLY executable !! ----
##-- ==> Define data, use random,
##-- or do help(data=index) for the standard data sets.
## The function is currently defined as
function ()
{
gridit <- locator()
points(gridit, pch = 16, col = "red")
X <- cbind(gridit$x, gridit$x^2)
m1 <- lm(gridit$y ~ X)
xpred <- seq(from = 1, to = 2, length = 500)
xpredM <- cbind(rep(1, 500), xpred, xpred^2)
ypred <- xpredM %*% coef(m1)
lines(xpred, ypred, col = "red", lwd = 1, lty = 3)
return(list(model = m1, data = data.frame(xpred = xpred,
ypred = ypred)))
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.