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

1 visualización (últimos 30 días)
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.

Respuesta aceptada

Walter Roberson
Walter Roberson el 2 de Jul. de 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

Más respuestas (0)

Categorías

Más información sobre Matrices and Arrays en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by