In [1]:
function my_lin_interp(grid, vals)
function func(x)
x_first=grid[searchsortedfirst(grid,x,)]
x_second=grid[searchsortedlast(grid,x,)]
y_first=vals[searchsortedfirst(grid,x,)]
y_second=vals[searchsortedfirst(grid,x,)]
y_first+(y_second-y_first)/(x_second-x_first)*(x-x_first)
end
return func
end
Out[1]:
In [ ]: