MATLAB: Converting Vector to matrix.

vector to matrix

Hello!
I want to convert vector:
V = [1 2 3 4 5 6 7 8 9]
To
V1 = [
1 2 3 4 5
2 3 4 5 6
3 4 5 6 7
4 5 6 7 8
5 6 7 8 9 ]
Is there a Matlab command that will let me do this? or this needs to be coded?
Thanks
KIB

Best Answer

It wasn't clear to me how general V might be, but I think this will do what you want.
V = 1:9;
N = numel(V);
N1 = ceil(N/2);
h = hankel(V);
V1 = h(1:N1,1:N1)