interpolation - Matlab spline function in Julia -
i trying interpolate 2 points in julia, using same approach of matlab (https://uk.mathworks.com/help/matlab/ref/spline.html). have tried interpolations (https://github.com/tlycken/interpolations.jl) library, having several issues in creating working script.
i have dataarrays.dataarray{float64,1} 2 points (let's 1.5 , 10.5) , 5 na between them:
using dataframes using interpolations = @data([1.5, na, na, na, na, na, 10.5]);
in matlab sufficient run spline function. in julia, interpolate function allows cubic interpolations. however, seems not working nas. how can it? also, use same / analogous algorithm interpolate points?
if make assumption evenly spaced, assuming linear interpolation can use linspace. need start, end, , number of values inbetween:
linspace(a[1],a[end],sum(isna(a)))
more generally, interpolation between nas, can find non-na values with
idxs = find(~isna(a))
and do
for in 1:length(idxs)-1 tmpidxs = idxs[i]:idxs[i+1] a[idxs[i]+1:idxs[i+1]-1] = linspace(a[idxs[i]],a[idxs[i+1]],length(tmpidxs))[2:end-1] end
you can clean or put in function if want. it's odd assumption though assume between each known value it's supposed linearly spaced.
Comments
Post a Comment