MATLAB: Subtract combinations of variables in a vector

MATLABvector permutations

I have a vector of 7 variables and I need to subtract the all possible combinations of one variable from another. I have tried to loop through the variables but I only get the first variable minus all the rest. I need the loop to continue to subtract variable 2 from the rest. Any help would be greatly appreciated.
for c=1:6; DER1(:,c)=DER(c); DER2(:,c)=DER(c+1);
for d=1:20;
DED(:,d) = DER1(c)-DER2(c);
end
end

Best Answer

If you have Statistics Toolbox, here's a neat trick (I think this is what you're asking for):
% make a vector of numbers
vec = rand(7,1)
% get inter-point "distances"
dfun = @(x,y) x-y;
pdist(vec,dfun)
% or if you prefer
squareform(pdist(vec,dfun))
EDIT TO ADD
As Teja suggested:
% as a matrix
bsxfun(@minus,vec',vec)
% as a vector
squareform(bsxfun(@minus,vec',vec))