繁体   English   中英

将样条插值转换为线性插值?

[英]Convert spline interpolation to linear interpolation?

下面的该函数在样条插值方面做得很好,但是我想知道如何修改它以进行线性插值!

  ## Function to interpolate using spline
    imageSpline = function(x, y, xout, method = "natural", ...){
    x.max = max(xout)
    x.spline = spline(x = x, y = y, xout = xout, method = method, ...)
    x.spline
    }

?approxapprox()approxFun() 这些是spline()splineFun()的线性插值副本。

根据要执行的线性插值的细节(有关详细信息和要调整的内容,请参阅?approx ),它可能很简单:

imageApprox <- function(x, y, xout, ...) {
    x.linear <- approx(x = x, y = y, xout = xout, ...)
    x.linear
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM