Suppose I have the inputs data = [1 2 3 4 5 6 7 8 9 10]
and num = 4
. I want to use these to generate the following:
i = [1 2 3 4 5 6; 2 3 4 5 6 7; 3 4 5 6 7 8; 4 5 6 7 8 9]
o = [5 6 7 8 9 10]
which is based on the following logic:
length of data = 10
num = 4
10 - 4 = 6
i = [first 6; second 6;... num times]
o = [last 6]
What is the best way to automate this in MATLAB?