.. highlightlang:: us .. _interpol: interpol ======== .. index:: interpol .. us.tag interpol ENGLISH Interpolation New420 Changed424 The :ref:`interpol` function executes a linear interpolation or cosine interpolation for the given x-coordinates. .. function:: rvYi = interpol(rvX, rvY, rvXi) rvYi = interpol(rvX, rvY, rvXi, rsMissing) rvYi = interpol(rvX, rvY, rvXi, rsMissing, ssType) .. us.return **Return Value** *rvYi* .. us.params **Parameters** .. uparam:: rvX *rvX* is a real vector with at least 2 elements. The coordinates must be sorted monoton increasing or decreasing. .. uparam:: rvY *rvY* is a real vector with at least 2 elements. The number of points must be identical with *rvX*. .. uparam:: rvXi *rvXi* is a real vector with at least one point. .. uparam:: rsMissing 1.) Values in *rvYi* >= *rsMissing* will be ignored in the interpolation. All elements in *rvYi* will be set to missing for *rvYi* >= *rsMissing*. 2.) If an extrapolation is necessary, the extrapolated values in *rvYi* are set to *rsMissing*. Default value is 0. .. uparam:: ssType *ssType* is a string with the text ``linear`` or ``cosine``. Default value is ``linear``. .. us.example **Example** .. image:: S:/uniplot-obj/images/interpol.* :: x = [1,3,5,8] y = [0,5,8,2] h = plot(x,y) yi = interpol(x, y, xi = linspace(1, 8, 5)); h = plot(xi, yi, h[2]) XYSetProps(h[3], "marker='1' marker-style='circle' curve-style='dash'"); x = [1,3,5,8] y = [0,5,8,2] h = plot(x,y) yi = interpol(x, y, xi = linspace(1, 8, 5)); h = plot(xi, yi, h[2], 1e10, "cosine") XYSetProps(h[3], "marker='1' marker-style='circle' curve-style='dash'"); If an error occures interpol returns an error object (see :ref:`error_create`). :: x = [1,3,4, 5,8] y = [0,5,8,2] yi = interpol(x, y, [1,2,2]); if (type(yi) == "error") { print yi.message; } .. us.history **History** .. list-table:: :header-rows: 1 * - Version - Description * - R2018.12 - New parameter *ssType* * - 4.2.4 - *rvXi* can be non-monotonic. * - 4.2.0 - New .. seealso:: :ref:`overview-mathematic`, :ref:`fspline`, :ref:`pspline`, :ref:`rspline`, :ref:`akimaspline` :sub:`id-2113436`