sgolayfilt              package:signal              R Documentation

_A_p_p_l_y _a _S_a_v_i_t_s_k_y-_G_o_l_a_y _s_m_o_o_t_h_i_n_g _f_i_l_t_e_r

_D_e_s_c_r_i_p_t_i_o_n:

     Smooth data with a Savitsky-Golay smoothing filter.

_U_s_a_g_e:

     sgolayfilt(x, p = 3, n = p + 3 - p%%2, m = 0, ts = 1)

     ## S3 method for class 'sgolayFilter':
     filter(filt, x, ...)

_A_r_g_u_m_e_n_t_s:

       x: signal to be filtered. 

       p: filter order. 

       n: filter length (must be odd). 

       m: return the m-th derivative of the filter coefficients.

      ts: time scaling factor. 

    filt: filter characteristics (normally generated by 'sgolay'. 

     ...: additional arguments (ignored). 

_D_e_t_a_i_l_s:

     These filters are particularly good at preserving lineshape while
     removing high frequency squiggles.

_V_a_l_u_e:

     The filtered signal, of 'length(x)'.

_A_u_t_h_o_r(_s):

     Original Octave version by Paul Kienzle pkienzle@users.sf.net.
     Modified by Pascal Dupuis. Conversion to R by Tom Short.

_R_e_f_e_r_e_n_c_e_s:

     Octave Forge <URL: http://octave.sf.net>

_S_e_e _A_l_s_o:

     'sgolay', 'filter'

_E_x_a_m_p_l_e_s:

     # Compare a 5 sample averager, an order-5 butterworth lowpass
     # filter (cutoff 1/3) and sgolayfilt(x, 3, 5), the best cubic
     # estimated from 5 points.
     bf = butter(5,1/3)
     x = c(rep(0,15), rep(10, 10), rep(0, 15))
     sg = sgolayfilt(x)
     plot(sg, type="l")
     lines(filtfilt(rep(1, 5)/5,1,x), col = "red") # averaging filter
     lines(filtfilt(bf,x), col = "blue")           # butterworth
     points(x, pch = "x")                          # original data

