See other catalogues for
The MathWorks
You may also be interested in
Text version of the page
| | | | | | | | | | | | | | | |
| | | |
| | | Differencing Data | | |
| | | |
| | | Differencing Data Three MATLAB® functions perform finite difference calculations. | | |
| | | |
| | | | | | | | | | Function | Description | | | | del2 | Discrete Laplacian of a matrix | | | | diff | Differences between successive elements of a vector; numerical partial derivatives of a vector | | | | gradient Numerical partial derivatives of a matrix | | | | | | | | | |
| | | |
| | | The diff function computes the difference between successive elements in a numeric vector. That is, diff(X) is [X(2)-X(1) X(3)-X(2). ..X(n)-X(n-1)j. You might want to perform this operation on your data ifyou are more interested in analyzing the changes in the values, rather than the absolute values. For a vector A, A = [9 -2 3 0 1 5 4]; diff(A) ans = -11 5-3 1 4-1 Besides computing the first difference, you can use diff to determine certain characteristics of vectors. For example, you can use diff to determine whether the vector values are monotonically increasing or decreasing, or whether a vector has equally spaced elements. | | |
| | | |
| | | The following table provides examples for using diff with a vector x. | | |
| | | |
| | | | | | | | | | Test | Description | | | | any(diff(x)==0) | Tests whether there are any repeated elements in X | | | | all(diff(x)>0) | Tests whether the values are monotonically increasing | | | | all(diff(diff(x))==0) Tests for equally spaced vector elements | | | | | | | | | |
| | | |
| | | 1-21 | | |
| | | |
| | | | | | | | | | | | | | | |