Skip to content

zero_crossing.m

Basic Information

  SYNTAX:  [zero_x_set,nearest_idx] = zero_crossing(x,y,plot_zeros)

  PURPOSE:  For a function defined by (x,y) data pairs, estimate the value(s)
    of x at which the function crosses y=0 (assuming linear interpolation
    between data points).

  INPUT:
    x,y = set of data pairs defining function
    plot_zeros = (optional) flag to plot zeros on top of function

  OUTPUT:
    zero_x_set = x values at which y=0
    nearest_idx = index of point nearest to the zero crossing

Dependencies