Getting Started
Use this page for the shortest path from installation to a first working spline. If you already know the workflow you want, jump to Common Tasks. If you want a guided walkthrough, go to Tutorials.
1. Install the package
Spline Core requires MATLAB R2024b or newer. Fitting workflows also depend on the Distributions package.
mpminstall("local/path/to/spline-core");
If you manage dependencies yourself, install without them explicitly:
mpminstall("local/path/to/spline-core", InstallDependencies=false);
For full install details, see Installation.
2. Choose the right starting point
| If your data are⦠| Start with | Next page |
|---|---|---|
| exact and trusted | InterpolatingSpline | Spline Interpolation |
| noisy or constrained | ConstrainedSpline | Fitting Noisy Data |
planar x(t), y(t) samples | TrajectorySpline | TrajectorySpline reference |
If you only remember one distinction, use InterpolatingSpline for exact interpolation, ConstrainedSpline for fitting, and TrajectorySpline when you want a shared-parameter planar trajectory model.
3. Exact interpolation quickstart
t = linspace(0, 1, 12)';
x = sin(2*pi*t);
f = InterpolatingSpline.fromGriddedValues(t, x, S=3);
tq = linspace(t(1), t(end), 200)';
xq = f(tq);
dxq = f.valueAtPoints(tq, D=1);
This gives you a reusable spline object for values and derivatives. For rectilinear grids, pass one grid vector per dimension:
F = InterpolatingSpline.fromGriddedValues({x, y}, V, S=[3 3]);
Vq = F(Xq, Yq);
4. Noisy fitting quickstart
t = linspace(0, 1, 50)';
xObs = exp(t) + 0.05*randn(size(t));
noiseModel = NormalDistribution(0.05);
fit = ConstrainedSpline.fromData(t, xObs, S=3, splineDOF=12, distribution=noiseModel);
tq = linspace(t(1), t(end), 200)';
xFit = fit(tq);
From the same starting point you can add robust error models, local point constraints, and global shape constraints. For rectilinear grids in two or more dimensions, switch to ConstrainedSpline.fromGriddedValues({x, y, ...}, values, ...).
5. Planar trajectory quickstart
t = linspace(0, 1, 24)';
x = cos(2*pi*t);
y = sin(2*pi*t);
trajectory = TrajectorySpline.fromData(t, x, y, S=3);
tq = linspace(t(1), t(end), 200)';
xq = trajectory.x(tq);
yq = trajectory.y(tq);
uq = trajectory.u(tq);
vq = trajectory.v(tq);
Use TrajectorySpline.fromData(...) for raw trajectory samples. The direct TrajectorySpline(t=t, x=xSpline, y=ySpline) constructor is the canonical solved-state path used for persisted restart and other bootstrap cases.
Where to go next
- Spline Interpolation
- Fitting Noisy Data
- Robust Fitting with Outliers
- Which Class Should I Use?
- Common Tasks
- BSpline Foundations
- TensorSpline Foundations
- TrajectorySpline Reference
- Class Documentation