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

1 view (last 30 days)
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.

Accepted Answer

Walter Roberson
Walter Roberson on 2 Jul 2021
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

More Answers (0)

Categories

Find more on Matrices and Arrays in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!