-3

私はいくつかのMatlabコードを見ています(ソフトウェアを持っていません)。私は次のことが何をしているのか疑問に思っています:

d=[0 diff(fM)]

ここで、fM 自体は配列です。

4

1 に答える 1

0

Octaveのヘルプ ドキュメントdiff(Matlab の同等の機能は、他の Matlab/octave 関数と同じように機能すると思います)

help diff
 `diff' is a function from the file /usr/share/octave/3.2.4/m/general/diff.m

 Function File:  diff (X, K, DIM)
 If X is a vector of length N, `diff (X)' is the vector of first
 differences  X(2) - X(1), ..., X(n) - X(n-1).

 If X is a matrix, `diff (X)' is the matrix of column differences
 along the first non-singleton dimension.

 The second argument is optional.  If supplied, `diff (X, K)',
 where K is a non-negative integer, returns the K-th differences.
 It is possible that K is larger than then first non-singleton
 dimension of the matrix.  In this case, `diff' continues to take
 the differences along the next non-singleton dimension.

 The dimension along which to take the difference can be explicitly
 stated with the optional variable DIM.  In this case the K-th
 order differences are calculated along this dimension.  In the
 case where K exceeds `size (X, DIM)' then an empty matrix is
 returned.

したがって、基本的に、エントリをdiff含むベクトルを返しますn - 1。投稿されたコードは、最初にゼロを追加して新しい配列を作成しているため、新しい差分ベクトルは入力ベクトルと同じサイズのままです (結果のベクトルは、別のルーチンで使用される可能性があります計算のために入力ベクトルの長さを想定しています。残りのコードがないと難しいです)、それが役立つことを願っています

于 2012-07-10T03:18:01.573 に答える