Finding same combination from two results
1 view (last 30 days)
Show older comments
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 Comments
Accepted Answer
Andrei Bobrov
on 11 Sep 2012
Edited: Andrei Bobrov
on 11 Sep 2012
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
More Answers (0)
See Also
Categories
Find more on Elementary Math in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!