Could anyone please help me how to extract the desired array size inside the cell.

1 回表示 (過去 30 日間)
I am a cell array
A=15x1 cell
1x1 cell-[1,2,3,4]
1x2 cell-[1,2,3] [4]
1x2 cell-[1,2,4] [3]
1x2 cell-[1,2] [3,4]
1x3 cell-[1,2] [3] [4]
1x2 cell-[1,3,4] [2]
1x2 cell-[1,3] [2,4]
1x3 cell-[1,3] [2] [4]
1x2 cell-[1,4] [2,3]
1x2 cell-[1] [2,3,4]
1x3 cell-[1] [2,3] [4]
1x3 cell-[1,4] [2] [3]
1x3 cell-[1] [2,4] [3]
1x3 cell-[1] [2] [3,4]
1x4 cell-[1] [2] [3] [4]
In this array I need to have only 1x2 cell inside which should contain only two numbers in each array i.e., [1,2] [3,4], [1,3] [2,4] and [1,4] [2,3].
Could anyone please help me on this.

採用された回答

Walter Roberson
Walter Roberson 2021 年 7 月 2 日
mask = cellfun(@(c)all(cellfun(@length, c) ==2),A)
A(mask)
The code would have to be changed if 2 2 2 can be observed

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by