interpolation - How to use R interp1 similarly as MATLAB's? -
i trying interpolate linearly in r. pseudocode u = interp1(u, linspace(1, numel(u), numel(u)-1)); in matlab extrapolation returns nan if point outside domain (default, more here ). approx rule=1 equivalent matlab pseudocode i not sure second interp1 parameter not required in matlab let unsuccessufully y <- x such interp1(x, y, xi, method = "linear") minimal code example (real 1 has > 500 k points linear work) , output @ top list of 2 $ : num [1:3] 1 2 3 $ : num [1:2] 1 2 num [1:2] 0 1 error in interp1(x, y, xi, method = "linear") : points 'xi' outside of range of argument 'x'. execution halted library("pracma") # http://finzi.psych.upenn.edu/library/pracma/html/interp1.html files <- vector("list", 2) files[[1]] <- c(1,2,3) files[[2]] <- c(1,2) str(files) # wanted, matlab: u = interp1(u, linspace(1, numel(u), numel(u)-1)); xi <- seq(0,1, len = length(files[[1]]) - 1) x <- files[[...