User`s guide
Difference
5-129
5Difference
Purpose Compute the element-to-element difference along rows or columns.
Library Math Functions / Math Operations
Description The Difference block computes the difference between adjacent elements in
rows or columns of the M-by-N input matrix
u.
Columnwise Differencing
When the Difference along parameter is set to Columns, the block computes
differences between adjacent column elements.
y = diff(u) % Equivalent MATLAB code
For sample-based inputs, the output is a sample-based (M-1)-by-N matrix
whose jth column has elements
For convenience, length-M 1-D vector inputs are treated as M-by-1 column
vectors for columnwise differencing, and the output is 1-D.
For frame-based inputs, the output is a frame-based M-by-N matrix whose jth
column has elements
The first row of the first output contains the difference between the first row of
the first input and zero. The first row of each subsequent output contains the
difference between the first row of the current input (time t) and the last row
of the previous input (time t-T
f
).
Rowwise Differencing
When the Difference along parameter is set to Rows, the block computes
differences between adjacent row elements.
y = diff(u,[],2) % Equivalent MATLAB code
y
ij,
u
i 1+ j,
u
ij,
1 iM1–()≤≤–=
y
ij,
u
i 1+ j,
u
ij,
2 iM≤≤–=
y
1 j,
t() u
Mj,
tT
f
–()u
1 j,
t()–=