In this case it's hard to avoid loops. You can go along the following lines:
ind = true(1,numel(TILER)); %// true indicates non-duplicate. Initiallization
for ii = 1:numel(TILER)-1
for jj = ii+1:numel(TILER)
if isequal(TILER{ii}, TILER{jj})
ind(jj) = false; %// mark as duplicate
end
end
end
TILER2 = TILER(ind);
Some optimizations are possible. For example:
- In the inner loop don't consider values that have been detected as duplicates in a previous iteration of the outer loop.
- Do a first check for equality of matrix sizes (this can be done efficiently with
bsxfun
), and then only test for equality between matrices that have the same size.