Finding same combination from two results

1 回表示 (過去 30 日間)
kash
kash 2012 年 9 月 11 日
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
  1 件のコメント
Jan
Jan 2012 年 9 月 11 日
I like "isequal(A{:})".

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeElementary Math についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by