# Documentation

### This is machine translation

Translated by
Mouseover text to see original. Click the button below to return to the English version of the page.

# col2im

Rearrange matrix columns into blocks

## Syntax

```A = col2im(B,[m n],[mm nn],'distinct') A = col2im(B,[m n],[mm nn],'sliding') ```

## Description

`A = col2im(B,[m n],[mm nn],'distinct')` rearranges each column of `B` into a distinct `m`-by-`n` block to create the matrix `A` of size `mm`-by-`nn`. If `B = [A11(:) A21(:) A12(:) A22(:)]`, where each column has length `m*n`, then ```A = [A11 A12; A21 A22]``` where each `Aij` is `m`-by-`n`.

`A = col2im(B,[m n],[mm nn],'sliding')` rearranges the row vector `B` into a matrix of size `(mm-m+1)`-by-`(nn-n+1)`. `B` must be a vector of size 1-by-`(mm-m+1)*(nn-n+1)`. `B` is usually the result of processing the output of `im2col(...,'sliding')` using a column compression function (such as `sum`).

`col2im(B,[m n],[mm nn])` is the same as ```col2im(B, [m n], [mm nn],'sliding')```.

## Class Support

`B` can be logical or numeric. The return value `A` is of the same class as `B`.

## Examples

collapse all

Create a matrix.

`B = reshape(uint8(1:25),[5 5])'`
```B = 5x5 uint8 matrix 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 ```

Rearrange the values in the matrix into a column-wise arrangement.

`C = im2col(B,[1 5])`
```C = 5x5 uint8 matrix 1 6 11 16 21 2 7 12 17 22 3 8 13 18 23 4 9 14 19 24 5 10 15 20 25 ```

Rearrange the values in the matrix back into their original row-wise orientation.

`A = col2im(C,[1 5],[5 5],'distinct')`
```A = 5x5 uint8 matrix 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 ```