.. highlightlang:: us .. _sgolayfilt: sgolayfilt ========== .. index:: smooth .. index:: Glätten .. index:: Golay .. index:: Savitzky-Golay .. index:: sgolayfilt .. us.tag sgolayfilt ENGLISH Interpolation New580 :ref:`sgolayfilt` computes a moving average using the Savitzky-Golay algorithm. .. function:: rvY2 = sgolayfilt(rvY1) rvY2 = sgolayfilt(rvY1, p) rvY2 = sgolayfilt(rvY1, p, nNeighbor) .. us.return **Return Value** The return value *rvY2* is a real vector. .. us.params **Parameters** .. uparam:: rvY1 *rvX* is a real vector with at least *p* elements. .. uparam:: p Order of polynom (1 to 10, default = 3). .. uparam:: nNeighbor *nNeighbor* specifies the window width. The window width is ``2 * nNeighbor + 1``. Default value = 20. .. us.example **Example** .. image:: S:/uniplot-obj/images/savitzky-golay.* :: def test_sgolay() { N = 200; t = linspace(0, 10, N); s = sin(2*PI/5*t); srand(1); sr = s + 0.3 * (rand(size(t))-0.5); // Sinus h = plot(t, s); XYSetProps(h[3], "curve-color='black'") XYSetLegendText(h[3], "sinus"); // sin+rand h = plot(t, sr, h[2]); XYSetProps(h[3], "curve-color='blue'") XYSetLegendText(h[3], "sinus+random"); y = moving_average(sr, 10) h = plot(t, y, h[2]); XYSetProps(h[3], "curve-color='red'") XYSetLegendText(h[3], "moving average (smooth())"); // smooth(sin+rand) y = sgolayfilt(sr, 3, 20); h = plot(t, y, h[2]); XYSetProps(h[3], "curve-color='green'") XYSetLegendText(h[3], "Savitzky-Golay Filter"); } .. us.history **History** .. list-table:: :header-rows: 1 * - Version - Description * - 5.8.0 - New .. seealso:: :ref:`overview-mathematic`, :ref:`pspline`, :ref:`fspline`, :ref:`akimaspline`, :ref:`interpol`, :ref:`moving_average` :sub:`id-931091`