フィルターのクリア

how to use Continue statement to compare between 2 cells and get their content only one time ?

1 回表示 (過去 30 日間)
All the cells of cell1(219*1) are existed in cell2 (244(219+15 repeated +10 others) . So i want to get the contents of those 219 [which exist in both cell1 and cell2] from cell3 and ignore the repeated onces(15 cells) using continue statement wich doesn't work with me!!!
  • cell1: size 219*1
  • cell2: size 244*1(219+15 repeated cells and 10 others)
  • cell3: size 244*1
i want to get cell3c of size 219*1 but i'm getting it of size 234*1 because of some repeated cells are also taken but i only need 219 no more!!
for i=1:1:rowcell1
for j=1:1:rowcell2
if isequal(cell1(i,:),cell2(j,:))
cell3c=[cell3c;cell3(:,j)] ;
continue
end
end
end
expected results cell3c:219*1 but i get 234*1

採用された回答

chocho
chocho 2017 年 3 月 27 日
for i=1:1:rowcell1
for j=1:1:rowcell2
if isequal(cell1(i,:),cell2(j,:))
cell3c=[cell3c;cell3(:,j)] ;
break
end
end
end

その他の回答 (1 件)

ES
ES 2017 年 3 月 24 日
If cell1 and cell2 are cell array of strings, you can use intersect.
  2 件のコメント
chocho
chocho 2017 年 3 月 24 日
cell1 and cell2 are having string and numbers also
chocho
chocho 2017 年 3 月 24 日
i'm using for Loop and use isequal is worked well. except the repeated issue whi i want to ignore

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

カテゴリ

Help Center および File ExchangeInteractive Control and Callbacks についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by