! Rebin a matrix

Rebin a matrix

Syntax: REBIN m mout nr nc

Suppose that matrix m has N rows and M columns, then:

that is, the matrix m will have N/nr rows and M/nc columns.

If    is not equal to N, then the last row of mout will be incomplete. If    is not equal to M, then the last column of mout will be incomplete.

Example

Suppose that M is a matrix with 8 rows and 6 columns.

commandresult
REBIN M MOUT 2 3
MOUT[1,1] = M[1,1]+M[2,1]+M[1,2]+M[2,2]+M[1,3]+M[2,3]
MOUT[1,2] = M[1,4]+M[2,4]+M[1,5]+M[2,5]+M[1,6]+M[2,6]
MOUT[2,1] = M[3,1]+M[4,1]+M[3,2]+M[4,2]+M[3,3]+M[4,3]
MOUT[2,2] = M[3,4]+M[4,4]+M[3,5]+M[4,5]+M[3,6]+M[4,6]
...

  Rebin a vector