The differences between the elements in a vector or a matrix. |
||
Syntax |
d = Diff(m,n,dim) |
|
Argument |
Name |
Description |
m |
A data vector or matrix. It must have at least 2 elements. |
|
n (optional) |
The number of iterative differences to be computed. The default is 1. |
|
dim (optional) |
The direction along which to take differences. For differences along columns, dim = 1. For differences along rows, dim = 2. If m is a matrix, dim defaults to 1. If m is a vector and dim is omitted, the differences are taken along the vector regardless of its orientation. |
|
Output |
Name |
Description |
d |
The vector of differences between the elements of m. Length(d) = Length(m) - n. |
|
Example 1 |
Find the vector of differences. |
|
Syntax |
||
D = Diff([1,2,4,7,11]) |
||
Result |
||
D = 1 2 3 4 |
||
Example 2 |
Find the vector of second differences. |
|
Syntax |
||
D = Diff([1,2,4,7,11], 2) |
||
Result |
||
D = 1 1 1 |
||
See Also: |