MATLAB: How to create a vector combinations in pairs

vector combinations

How do I create a vector combinations in pairs ,with no repeated elements ,for example :
A(1,2,3,4)
1,2
1,3
1,4
2,1
2,3
2,4
3,1
3,2
3,4
4,1
4,2
4,3
I tried to use some commands like : perms And combnk , thanks in advanced

Best Answer

a=fliplr(fullfact([4 4]))
a(~diff(a')',:)=[]
or
[ii,jj]=ndgrid(1:4,1:4);
a=[jj(:) ii(:)];
a(~(a(:,1)-a(:,2)),:)=[]