Gapsegment

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Contents

Purpose

Provides Gap-Segment derivatives.

Synopsis

[y_hat,cm] = gapsegment(y,order,gap,segment,options);
gapsegment demo

Description

Calculates a derivative in which the two values being subtracted from each other are not single adjacent points (as in a point difference derivative, where, for example, Dx1=x2-x1) but a derivative where there are multiple points in each "segment" (i.e. window) and the segments are separated by some non-zero number of points.

The filter is determined by the order of derivative (which defines the number of segments), segment size (number of variables in each window) and gap size (number of variables between the windows).

The filter (F) for each order is given as [g = gap, s = segment]

order = 1
F = [-ones(1,s) zeros(1,g) ones(1,s)];
order = 2
F = [ ones(1,s) zeros(1,g) -2*ones(1,s) zeros(1,g) ones(1,s)];
order = 3
F = [-ones(1,s) zeros(1,g) 3*ones(1,s) zeros(1,g) -3*ones(1,s) zeros(1,g) ones(1,s)];
order = 4
F = [ ones(1,s) zeros(1,g) -4*ones(1,s) zeros(1,g) 6*ones(1,s) zeros(1,g) -4*ones(1,s) zeros(1,g) ones(1,s)];

Inputs

• first = first input is this.
• y = MxN matrix where rows are to be filtered.
• order = order of derivative (1, 2, 3 or 4)
• gap = the gap size, the number of variables between segments. Must be >2 and odd.
• segment = the segment size, the number of variables in each segment. Must be >2 and odd.

Optional Inputs

• options = an optional input options structure (see below)

Outputs

• y_hat = is the filtered data.
• cm = is the filter matrix such that y_hat = y*cm;

Options

options = a structure array with the following fields:

• algorithm: [ {standard} | savgol ]