- Simple plot
- Derivative function
- Polyline / Markers
- Multiple plots
- Logarithmic axis
- Adding positions manually
- Steep rise (polyline)
- Data points, splines (theory)
- Data points, splines (examples)
- Parametric plot
- Parametric points
- PDF+TeX
- License
- Installation
- Tutorial
- Reference
- FAQ
- Technical details
- Changes
- Related projects

3 Tutorial |

For demonstration purposes we plot different splines through the following points:

Point no. | x |
y |
---|---|---|

1 | 1 | 2 |

2 | 2 | 2 |

3 | 3 | 2 |

4 | 4 | 2 |

5 | 5 | 2 |

6 | 6 | 1 |

7 | 7 | 7 |

8 | 8 | 1 |

9 | 9 | 2 |

10 | 10 | 2 |

11 | 11 | 2 |

12 | 12 | 2 |

13 | 13 | 2 |

File example16.m creates a not-a-knot spline.

This is the default spline type, also used by
*interp1()*.

File example17.m creates a natural spline.

Natural splines are used for smooth curves.

File example18.m creates a periodic spline.

In the example the first and second derivative must be equal in the last and first point. Due to the symmetric configuration it is 0 here.

File example19.m creates a fast spline.

The impact of each point is restricted to four intervals (two intervals left from the point, two intervals right from the point).

File example20.m creates
approximated X-splines using different *s* values.

The black curve uses the default value *s*=1 for all inner
points. This curve doesn't touch points 6, 7, and 8.

For the blue curve we decreased *s* to *s=1/2* in points
6, 7, and 8. This drags to curve nearer to the point.

For the red curve we changed *s* to *s*=0 for points 6,
7, and 8. These points are now corner points of the curve.

File example21.m creates
several interpolated X-splines using different *s* values.

The black curve uses the default value *s*=-1 for all inner
points.

For the blue curve we changed *s* to *s*=-1/2 for points
6, 7, and 8. Now the curve radii in these points are smaller.

For the red curve we changed *s* to *s*=0 for points 6,
7, and 8. These points are now corner points of the curve.

In file example22.m we modify the
not-a-knot-spline seen in the first example.

If we know points 6 and 8 are local minimum points and point 7 is
the local maximum we set the first derivative value to 0 in these
points (third column in the M matrix). For all other points we
dont't specify a value for the first derivative, so we use NA.

We are not restricted to minimum and maximum points, we can
specify a value for the first derivative for any point.

In example file example23.m we set the
first derivative for point 3 to 10.

For a permanent magnet we have measurement values for the
*B*=*f*(*H*) curve:

Point no. | H in A/cm |
B in T |
---|---|---|

1 | -350.0 | 0.0 |

2 | -313.3 | 0.25 |

3 | -280.0 | 0.36 |

4 | -220.0 | 0.47 |

5 | -146.7 | 0.56 |

6 | -80.0 | 0.61 |

7 | 0.0 | 0.65 |

Example files example24.m and example25.m draw
two variants of the diagram. As the unit for *H* is very long
we write the axis labels as a fraction.

For a two stage amplifyer we did an experimental DC wobbling analysis to find a suitable BIAS point. The measurement results are shown in the table below.

Point no. | U_{B1} in V |
U_{C2} in V |
---|---|---|

1 | 0.340 | 0.10 |

2 | 0.350 | 0.15 |

3 | 0.356 | 0.19 |

4 | 0.365 | 0.273 |

5 | 0.370 | 0.33 |

6 | 0.375 | 0.40 |

7 | 0.380 | 0.48 |

8 | 0.385 | 0.58 |

9 | 0.390 | 0.72 |

10 | 0.395 | 0.86 |

11 | 0.400 | 1.05 |

12 | 0.405 | 1.25 |

13 | 0.410 | 1.55 |

14 | 0.415 | 1.85 |

15 | 0.420 | 2.25 |

16 | 0.425 | 2.68 |

17 | 0.430 | 3.26 |

18 | 0.435 | 3.84 |

19 | 0.440 | 4.69 |

20 | 0.445 | 5.40 |

21 | 0.450 | 6.68 |

22 | 0.455 | 7.80 |

23 | 0.460 | 9.50 |

24 | 0.465 | 10.90 |

25 | 0.470 | 12.76 |

26 | 0.475 | 14.55 |

27 | 0.480 | 15.00 |

28 | 0.485 | 15.10 |

29 | 0.490 | 15.10 |

30 | 0.495 | 15.10 |

The image below was created using file example26.m and shows the measurement points as markers.

In example file example27.m we use a spline interpolation.

In example file example28.m we use a spline interpolation again. For the final 3 points we set the first derivative to 0.

In example file example29.m we use an
open approximated X-spline.

I think the result looks better than the two examples before.

The curve does not touch point 26 and 27.

In example file example30.m we set
*s*_{26}=-1 and *s*_{27}=-0.5 to make
sure the curve touches these points. Points 26 and 27 are now
interpolation points.

Dirk Krause

Schmalkalden, 2017-09-24