MATLAB: How to create a sqaure matrix from a one dimensional vector

matrix

Hi all,
I want to create a n*n matric from a 1*n matrix such that all possible every column is the shifted version of the previous one. For example, 1 2 3 4 then matrix should look like
1 2 3 4
2 3 4 1
3 4 1 2
4 1 2 3
Thanks

Best Answer

x = 1:4;
gallery('circul',x) %gallery strikes again!
More
fliplr(gallery('circul',fliplr(x)))
since you want it shifted to the left.