Removing duplicate rows of matrices from a cell array.

I have a 32x32 cell array which all either contain X,Y coordinates or are empty (I have attached an image of the array to give an example of it's structure).
The top row is identical to rows 2:10, the 11th row is the same as rows 12 & 13, the 14th row is the same as rows 15:19 etc...
I want to sort the cell array so instead of a 32x32, it becomes a 6x32 (in this case; there won't always be 6 unique rows) where each row is unique.
Any help would be greatly appreciated; please let me know if any additional info is required.

 Accepted Answer

Managed to solve it myself (with a lot of fiddling around!):
Where 'a' is the 32x32 cell array:
RemoveIndex = [];
for i=1:size(a,1)-1
for j=1:length(a)
if ~isempty(a{i,j}) && ~isempty(a{i+1,j})
if (a{i,j})-(a{i+1,j})==0
RemoveIndex = [RemoveIndex,i+1];
end
end
end
end
RemoveIndex = unique(RemoveIndex)
b=a;
b(RemoveIndex,:)=[];

More Answers (0)

Categories

Products

Asked:

on 3 Nov 2016

Answered:

on 3 Nov 2016

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!