2012-07-10 69 views
-3

我在看一些Matlab代碼(沒有軟件)。我想知道以下幾點:Matlab組合陣列

d=[0 diff(fM)] 

其中fM本身就是一個數組。

回答

0
在八度 diff(我suppouse Matlab的等效工作方式相同與任何其他基於Matlab /倍頻功能)

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條目的載體,發佈的代碼是創建一個新的數組在開始添加一個零,所以新的差異向量保持與輸入向量相同的大小(也許生成的向量將用於另一個假定計算的輸入向量長度的例程,但是如果沒有剩餘的代碼),希望它有幫助