derivative of y with respect to x
dydx = diffxy(x, y) dydx = diffxy(x, y [, N, dim])
scalar, vector or matrix of doubles
vector or matrix of doubles
integer, the order of differentiation. Default value: 1.
integer or string, Available values: 1, 2, "r" and "c". Default value: find(size(y) > 1, 1)
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.
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)"]) | ![]() | ![]() |

| Version | Description |
| 2025.1.0 | Introduction in Scilab. |