I have a cell matrix TILER that include some matrix with different sizes.
TILER=[22x4 double] [1265x4 double] [58x4 double] [31x4 double] [58x4 double]
and we know that some matrixes are duplicate, for example [58x4 double]
matrix.
how can we remove duplicate matrixes from a cell array to have :
TILER=[22x4 double] [1265x4 double] [58x4 double] [31x4 double]
here is a link, but it doesn't work
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:
bsxfun
), and then only test for equality between matrices that have the same size.