batchpolyfit

Polyfit plus batch digital filter. batchpolyfit fits a polynomial to the data and subtracts that polynomial from the data, leaving only the residuals. It batch filters the residuals, then adds the polynomial back in.

Syntax

batchpolyfit(x, y, low_cutoff, high_cutoff, poly_order)

Argument

x
The x vector of the curve to be filtered.
y
The y vector of the curve to be filtered.
low_cutoff
The low cutoff frequency (scalar expression).
high_cutoff
The high cutoff frequency (scalar expression).
poly_order
The order of the resultant polynomial (scalar expression).

Example

Curve Math Vectors Result
x = c1.x

y = batchpolyfit(c1.x, c1.y, 5, 8, 3)

Given c1, a curve is created which is filtered through an ideal band-pass filter with low cutoff frequency 5 and high cutoff frequency 8 and of the third-order.

Comments

The batchpolyfit filter filters all points on a curve at once, or in a "batch." A Fast Fourier Transform (FFT) is used to transform the data into the frequency-domain where it is filtered. An inverse IFFT is then used to transform the data back into the time-domain. The resultant vector is the original curve filtered through an ideal filter with low and high cutoff frequencies.

It is assumed that the data is evenly sampled.

indep_vec and dep_vec must have the same number of elements. Both low and high must be non-negative.

To create a band-pass filter, specify a high cutoff frequency (fhigh) that is greater than the low cutoff frequency (flow).





To create a notch filter, specify a high cutoff frequency (fhigh) that is less than the low cutoff frequency (flow).

High-pass and low-pass filters are handled in the same manner as band-pass and notch filters. For a low-pass filter, the low cutoff frequency should be zero. For a high-pass filter, the high cutoff frequency should be zero.

If the cutoff frequency is greater than half the sampling Nyquist frequency, the curve is not filtered.

If the optional extension argument is used, the vector is extended at the beginning and end by extension points before filtering. These points are not present in the result. Using this option usually provides better accuracy at the ends of the resultant curve.