ymn
ymn

Reputation: 2153

Interpolation of a data set

I am developing an linux kernel module in which I want to evaluate the level of battery power supply. I measured the voltage on the battery during charging. As a result, I received the experimental dependence such as:

10:28:15    7898
10:29:15    7902
10:30:15    7908
10:31:15    7913
10:32:15    7918
10:33:15    7921

enter image description here

Now I need to interpolate the resulting graph with second-degree polynomial.

How can I do this with R programming language?

Upvotes: 0

Views: 202

Answers (1)

Tim
Tim

Reputation: 14154

Use lm to fit a linear model to data:

> x <- 0:9
> y <- 1+2*x+3*x^2
> fit <- lm( y ~ x + I(x^2) )
> fit

Call:
lm(formula = y ~ x + I(x^2))

Coefficients:
(Intercept)            x       I(x^2)  
          1            2            3  

But you should probably reconsider your quadratic model of this data.

Upvotes: 3

Related Questions