interp1

Core Math

1-D interpolation. Methods: 'linear' (default), 'nearest', 'cubic', 'spline'. Returns NaN for query points outside the data range.

Syntax

interp1(x, y, xq)
interp1(x, y, xq, 'linear')
interp1(x, y, xq, 'nearest')
interp1(x, y, xq, 'spline')

Examples

interp1([0, 1, 2], [0, 2, 4], 0.5)
▶ Run
interp1(x, y, xq, 'spline')
▶ Run

See Also

Try SimLab — Free MATLAB® Alternative

466 functions. Runs in your browser. No install.

Open SimLab

Stay Updated

Get notified about new simulations and tools. We send 1-2 emails per month.