This is the top non-zero square of a Hankel matrix. Just use hankel
:
>> X = hankel(x)
X =
1 3 5 6 7
3 5 6 7 0
5 6 7 0 0
6 7 0 0 0
7 0 0 0 0
>> X = X(1:3,1:3)
X =
1 3 5
3 5 6
5 6 7
Generalized, hankel
output specified exactly:
w = floor(numel(x)/2);
X = hankel(x(1:end-w),x(w+1:end))