Do you have a signal processing toolbar? Then the buffer command. First look at the bare output:
buffer(v, 4, 2) ans = 0 1 3 5 7 9 11 0 2 4 6 8 10 12 1 3 5 7 9 11 13 2 4 6 8 10 12 0
This is clearly the right idea, with a little tweaking necessary to give you exactly what you want:
[yz] = buffer(v, 4, 2, 'nodelay'); y.' ans = 1 2 3 4 3 4 5 6 5 6 7 8 7 8 9 10 9 10 11 12
However, consider leaving vectors in half, as this is better suited to most use cases. For example, the average for each window is simply mean matrix, because the default column is.
Peter
source share