deriv.m
SYNTAX: [xderiv,tderiv] = deriv(x,t,method)
PURPOSE: Calculate approximate derivative of vector or matrix.
INPUT:
x = column vector or matrix to differentiate
t = times corresponding to x data (column vector), or
time between samples (scalar)
method = differentiation method (optional, default=1)
1 = forward difference
2 = backward difference
3 = average of forward and backward difference
4 = produces correct derivative for times BETWEEN input samples
(Strictly speaking, derivative is undefined at sample points for
piecewise linear signal)
OUTPUT:
xderiv = approximate derivative vector = dx/dt, at input times if method<4,
at constructed time vector tderiv if method=4.
tderiv = input t if method<4. Strictly contains t if method=4.
If x is a matrix, each column must represent data sampled at times given
by vector t.
RESTRICTIONS:
(1) Time t must column vector with values in ascending order.
Dependencies