Q:

Change orientation of buffer function

I need a function that splits a vector in smaller frames with an overlap, like buffer, but instead of column-wise, it should be done row-wise.
This is how buffer works:
x = 1:20
x = buffer(x, 10, 5);

x =  0     1     6    11
     0     2     7    12
     0     3     8    13
     0     4     9    14
     0     5    10    15
     1     6    11    16
     2     7    12    17
     3     8    13    18
     4     9    14    19
     5    10    15    20

What I want would be this though:
x =  0    0    1    2
     1    2    3    4
     3    4    5    6
     5    6    7    8
     7    8    9   10
     9   10   11   12
    11   12   13   14
    13   14   15   16
    15   16   17   18
    17   18   19   20

Is there any function or way to achieve that? Maybe combination of buffer + some rearranging?

A:

First figure out the answer in columns, then transpose the resulting matrix:
buffer(x, 4, 2).'

