Data Analysis - The MathWorks - #29

/ 220


catalogue search
P. 01
P. 02
P. 03
P. 04
P. 05
P. 06
P. 07
P. 08
P. 09
P. 10
P. 11
P. 12
P. 13
P. 14
P. 15
P. 16
P. 17
P. 18
P. 19
P. 20
P. 21
P. 22
P. 23
P. 24
P. 25
P. 26
P. 27
P. 28
P. 29
P. 30
P. 31
P. 32
P. 33
P. 34
P. 35
P. 36
P. 37
P. 38
P. 39
P. 40
P. 41
P. 42
P. 43
P. 44
P. 45
P. 46
P. 47
P. 48
P. 49
P. 50


See other catalogues for The MathWorks

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

pageCatalog pdf di En 2012-06-22-01