Matlab combination array -


I'm looking at some matlab code (not software) I'm wondering what the following does:

  d = [0 diff (fm)]   

Where FM itself is an array. Support documentation for diff in Octave (I support Macmill equivalent) Like any other Matlab / octave functions)

  Help file diff 'diff' is a function from /usr/share/octave/3.2.4/m/general/diff.m file function File: diff (X, K, DIM) If x is a vector of length, then 'difference (x)' first difference is x (2) - x (1), ..., x (n) - x (n - 1)). If X is the matrix, then 'difference' (x) 'is the matrix of column difference with the first non-singular amplitude. The second argument is optional. If the supply has been made, `difference (x, k) ', where there is a non-negative integer, then in Kashmir difference it is possible that K is greater than the non-singleton dimension of the matrix. In this case, 'difference' continues with differences with the next non-singleton dimension. The difference with which to take the difference is that the optional variable can be explicitly said with the DIM. In this case the K-th sequence difference is calculated with this dimension. In case where Kashmir is more than `size (X, DIM) 'then an empty matrix is ​​returned.   

So basically, diff returns a vector with n - 1 entries, which were posted at zero Adding a new array is the beginning so the new difference vector can be the same vector as the input vector (The result is that the vector is being used in the second routine which calculates the input vector length for the calculation; Without difficulty), hope that it helps

Comments