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

采纳的回答

Andrei Bobrov
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 个)

类别

Help CenterFile Exchange 中查找有关 Elementary Math 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by