diffxy
derivative of y with respect to x
Syntax
dydx = diffxy(x, y) dydx = diffxy(x, y [, N, dim])
Arguments
- x
scalar, vector or matrix of doubles
- y
vector or matrix of doubles
- N
integer, the order of differentiation. Default value: 1.
- dim
integer or string, Available values: 1, 2, "r" and "c". Default value: find(size(y) > 1, 1)
Description
dydx=diffxy(x, y) compute the derivative of y with respect to x.
dydx will be the same size as y.
diffxy also handles unequally spaced data and treats the edges using the higher accuracy.
dydx = diff(x, y, N, dim) is the Nth
difference function along dimension dim.
Default value for N is 1. Default value for
dim is find(size(y) > 1, 1).
dim='r' is equivalent to dim=1
and dim='c' is equivalent to
dim=2.
Examples
Equally spaced data
clf(); x = linspace(0, %pi, 1e3); y = cos(x); dy = diffxy(x, y); plot(x, -sin(x), "ro", x, dy, "k*"); legend(["-sin(x)", "diffxy(x, y)"]);
Unequally spaced data
clf(); x = linspace(0, %pi, 1e3) + rand(1, 1e3, "normal") * 0.1; y = cos(x); dy = diffxy(x, y); plot(x, -sin(x), "ro", x, dy, "k*"); legend(["-sin(x)", "diffxy(x, y)"])

See also
- diff — Difference and discrete derivative
History
| Version | Description |
| 2025.1.0 | Introduction in Scilab. |
| Report an issue | ||
| << diff | Equations différentielles | impl >> |