how to delete rows in cell array
Mostrar comentarios más antiguos
In my cell array, i have rows with random letters and numbers and rows where every element is 1.Those rows are randomly generated so i dont know their position. How can i delete every row of 1 without knowing their position?
1 comentario
madhan ravi
el 4 de Nov. de 2018
a snippet of your cell array?
Respuesta aceptada
Más respuestas (1)
per isakson
el 4 de Nov. de 2018
Editada: per isakson
el 4 de Nov. de 2018
Try
%%I assume that your cell array is somewhat similar to this one
cac = { 'a','b','c'
[1],[2],[3]
'a','b','c'
[1],[1],[1]
'a','b','c'
[1],[2],[3]
};
is_one = cellfun( @(element) isnumeric(element) && element==1, cac );
is_row_of_ones = all( is_one, 2 );
cac( is_row_of_ones, : ) = []
which outputs
cac =
5×3 cell array
{'a'} {'b'} {'c'}
{[1]} {[2]} {[3]}
{'a'} {'b'} {'c'}
{'a'} {'b'} {'c'}
{[1]} {[2]} {[3]}
and see the Matlab documentation
Categorías
Más información sobre Multidimensional Arrays en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!