Skip to content

Commit 3fcc740

Browse files
committed
Fix interpolate function
1 parent 6dfd4b9 commit 3fcc740

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/functions.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ function interpolate(x, yvalues::Tuple{Vararg{Float64}}, xrange::Tuple{Float64,
1313

1414
# y gets the min y value if less than the min x range
1515
# or the max y value if greater than the max x range
16-
y = (x < xrange[1]) * yvalues[1] + (x > xrange[2]) * yvalues[end]
16+
y = (x < xrange[1]) * yvalues[1] + (x xrange[2]) * yvalues[end]
1717

1818
# in case x is inside the range, y gets the interpolated value
1919
for i 1:length(yvalues)-1
20-
y += (x xvalues[i]) * (x xvalues[i+1]) * interpolate(x, xvalues[i], xvalues[i+1], yvalues[i], yvalues[i+1])
20+
y += (x xvalues[i]) * (x < xvalues[i+1]) * interpolate(x, xvalues[i], xvalues[i+1], yvalues[i], yvalues[i+1])
2121
end
2222

2323
return y

0 commit comments

Comments
 (0)