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.

 채택된 답변

steven
steven 2016년 11월 3일
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,:)=[];

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Shifting and Sorting Matrices에 대해 자세히 알아보기

제품

질문:

2016년 11월 3일

답변:

2016년 11월 3일

Community Treasure Hunt

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

Start Hunting!

Translated by