Binary approach (however, it might get slow for large numbers of element in x)
%vectorized method of this approach might be a little faster
x=[1 2 3 4];
y=[];
for i=1:2^numel(x)-1
if nnz(dec2bin(i,numel(x))=='1')==3
y=[x(dec2bin(i,numel(x))=='1'); y];
end
end
y
