| Syntax: |
matrix = FOLD( vector, scalar )
|
The FOLD function has two arguments. The first
must be a vector, and the second a scalar. The result is a matrix formed by folding the
data in the vector into the columns of a matrix.
Suppose that vector x has m elements. Then
FOLD(x,n)[i,j] = x[i+(j-1)*n]
for i = 1,2,...,n and j = 1,2,...,m/n.
Note that m must be divisible by n.
Examples
| function | result | ||||
FOLD([1:12],3) |
|
||||
FOLD([1:12],4) |
|
| Note: | if M is a matrix with R rows, thenFOLD(UNFOLD(M),R) is equal to M |
if X is a vector and N is a scalar such than
LEN(X) is divisible by N, thenUNFOLD(FOLD(X,N)) is equal to X |