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

1 Ansicht (letzte 30 Tage)
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.

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 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

Weitere Antworten (0)

Kategorien

Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by