Finding same combination from two results
조회 수: 1 (최근 30일)
이전 댓글 표시
I have values as follows
result=
{8x2 cell}
{7x2 cell}
{6x2 cell}
{5x2 cell}
{4x2 cell}
{3x2 cell}
result1=
result=
{6x2 cell}
{5x2 cell}
{4x2 cell}
{3x2 cell}
the size of result and result1 are different(differemt number of rows but same columns)
now i want to find the Parameters which are same in both result and result1
please help
댓글 수: 0
채택된 답변
Andrei Bobrov
2012년 9월 11일
편집: Andrei Bobrov
2012년 9월 11일
A = {result;result1};
[i0,i0] = sort(cellfun(@numel,A),'descend');
[m1,n1] = cellfun(@size,result);
[m2,n2] = cellfun(@size,result1);
A1 = {[m1,n1];[m2,n2]};
A2 = A1(i0);
[i1,i2] = ismember(A2{:},'rows');
out = isequal(A2{1}(i1),A2{2});
OR
[m1,n1] = cellfun(@size,result);
[m2,n2] = cellfun(@size,result1);
[i1,i2] = ismember([m1,n1],[m2,n2],'rows');
A = {result(i1),result1(i2(i1))};
if isequal(A{:})
out = A{1};
else
out = [];
for jj = 1:numel(A{1})
if isequal(A{1}(jj),A{2}(jj))
out = [out;A{1}(jj)];
end
end
end
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!