Borrar filtros
Borrar filtros

I want to find the position of cells with a specific content, but the empty cells are not counted, so I take a wrong result of position

1 visualización (últimos 30 días)
I have the cell array a.
This cell array is a 1603 * 1 cell array .
I want to find the cells that contain 'svinw to ena zeugos', so this is what I did:
b=find(ismember([a{:,1}],{'svinw to ena zeugos'}));
But the rows that are empty (only contain [] ) are not counted, so the array b finds wrong rows that contain 'svinw to ena zeugos'.
What can I do?

Respuestas (1)

Star Strider
Star Strider el 11 de Nov. de 2021
The ‘b’ variable will contain the numeric indices from the logical vector that ismember returns, so ‘a{b,1}’ should return the desired results.
Lv = randi([0 1], 1, 10) == 1
Lv = 1×10 logical array
0 0 0 1 0 0 0 0 1 1
Nv = find((Lv))
Nv = 1×3
4 9 10
.
  2 comentarios
Ioannis Vourvachakis
Ioannis Vourvachakis el 11 de Nov. de 2021
Editada: Ioannis Vourvachakis el 11 de Nov. de 2021
Τhe problem I describe is the following:
If I write b=ismember([a{:,1}],{'svinw to ena zeugos'});
b is a 1*1268 logical array, not the same dimensions as the array a.
This is happening because in array a the empty cells ( only contain [] ) are not counted.
I want the array b to have the same dimensions as array a.
The cell array a seems like

Iniciar sesión para comentar.

Categorías

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

Community Treasure Hunt

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

Start Hunting!

Translated by