# MATLAB: Removing duplicate rows of matrices from a cell array.

cell arraysdelete rowsduplicateMATLABmatricesstructures

I have a 32×32 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 32×32, it becomes a 6×32 (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.

#### Best 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,:)=[];