Skip to content

Commit 4857d28

Browse files
Add simple example to docs and readme
1 parent af35e77 commit 4857d28

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

docs/src/index.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,23 @@ Pkg.add("Interpolations")
3636
```
3737

3838
from the Julia REPL.
39+
40+
## Example Usage
41+
Create a grid `xs` and an array `A` of values to be interpolated
42+
```
43+
xs = 1:0.2:5
44+
f(x) = log(x)
45+
A = [f(x) for x in xs]
46+
```
47+
Create linear interpolation object without extrapolation
48+
```
49+
interp_linear = LinearInterpolation(xs, A)
50+
interp_linear(3) # exactly log(3)
51+
interp_linear(3.1) # approximately log(3.1)
52+
interp_linear(0.9) # outside grid: error
53+
```
54+
Create linear interpolation object with extrapolation
55+
```
56+
interp_linear_extrap = LinearInterpolation(xs, A,extrapolation_bc=Line())
57+
interp_linear_extrap(0.9) # outside grid: linear extrapolation
58+
```

0 commit comments

Comments
 (0)