This should give you an idea of how to go about it:
A = [1 1 1
1 1 2
1 1 3
1 2 1
1 2 2
1 2 3
1 3 1
1 3 2
1 3 3
2 1 1
2 1 2
2 1 3];
A(any((A == 1)') & any((A == 2)') & any((A == 3)'),:)
ans =
1 2 3
1 3 2
2 1 3
Or generically using a loop (with only 4 number this should be pretty fast):
rows = true(size(A,1),1); %// Initialization
U = unique(A); %// List of numbers
for n = 1:size(U,1)
rows = rows & any((A == U(n))')';
end
A(rows,:)