I am using this block of code to get all the possible combinations of the rows of the matrix having thee rows. The code is as follows:
sample = [1 1 ; 2 2; 3 3];
v = [];
for i = 1:size(sample,1)-1
v = [v;(sample(i,:))];
for j = 1:size(sample,1)
if isequal(ismember(sample(j,:),v,'rows'),0)
display([v;sample(j,:)]);
else
j = j+1;
end
end
end
This code gives me the following output:
ans =
1 1
2 2
ans =
1 1
3 3
ans =
1 1
2 2
3 3
But I need output like this:
ans =
1 1
ans =
2 2
ans =
3 3
ans =
1 1
2 2
ans =
1 1
3 3
ans =
2 2
3 3
ans =
1 1
2 2
3 3
Only a small change would be enough to get the desired result.