Qu

gradient

Builtin index · Core maths

result = gradient(v, [h])

Input: v, h · Output: result

What it is

Numerical derivative of the samples in the Vec v (at least two): central differences in the interior, (v[i+1]-v[i-1])/(x[i+1]-x[i-1]), which is exact for a quadratic on a uniform grid, and one-sided differences at the two ends. h is a uniform spacing (number, default 1; a Signal's sample rate is not used) or a coordinate Vec of the same length as v with distinct consecutive values.

Overloads

One call shape — this function is not overloaded.

CodeInputOutputDescription
result = gradient(v, [h])
v VecNumerical derivative of the samples in the Vec v (at least two): central differences in the interior, (v[i+1]-v[i-1])/(x[i+1]-x[i-1]), which is exact for a quadratic on a uniform grid, and one-sided differences at the two ends.
h number, optionalh is a uniform spacing (number, default 1.
result Vec or matrix
Returns a Vec the length of v. Errors: fewer than two samples, a zero or non-finite spacing, a coordinate Vec of the wrong length, a matrix argument.

Examples

No documentation example calls this form yet. The Core maths chapter is where one belongs.