Check if one cell is comprised in other cells of an array?

2 ビュー (過去 30 日間)
Andrew Poissant
Andrew Poissant 2018 年 7 月 27 日
編集済み: Andrew Poissant 2018 年 7 月 27 日
I have a variable, var (see attached .mat file), that is a 1x7 cell array. It has the following cells: {766×2 double} {766×2 double} {766×2 double} {766×2 double} {766×2 double} {766×2 double} {766×2 double}.
I want to see if each row of a cell is comprised in another one of the cells in the array. If every single row of a cell is comprised in any of the other cells, then delete that cell. How would I do that? For example, if each row in the first {722x2 double} cell is comprised in any of the other six {766x2}, then delete the first cell.

回答 (1 件)

Jan
Jan 2018 年 7 月 27 日
Use ismember('rows') and a loop:
found = true;
for k = 2:7
found = found & ismember(v{1}, v{k}, 'rows');
end
v{1} = v{1}(~found);
  1 件のコメント
Andrew Poissant
Andrew Poissant 2018 年 7 月 27 日
編集済み: Andrew Poissant 2018 年 7 月 27 日
how would I generalize this procedure to apply it to the other 6 cells in the array? Also, when I try this with my cell array I uploaded, all it is doing is deleting a row of cell one and some of the columns? What I am looking for is if every row in a cell is shared in any of the other cells in the array, then delete that cell from the array.

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

カテゴリ

Help Center および File ExchangeCell Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by