Borrar filtros
Borrar filtros

Remove row of cell array that contains 0.

4 visualizaciones (últimos 30 días)
Chin
Chin el 16 de En. de 2012
For example, I have a = [{0} {0} {0}; {1} {3} {4}; {0} {0} {0}]. I would like to remove the row that contains all of zero so that I can have the result a = [{1} {3} {4}]. I try this but it not work.
a(all(a == 0, 2), :) = []
what I am missing? Thanks.

Respuesta aceptada

Andrei Bobrov
Andrei Bobrov el 16 de En. de 2012
out = a(all(cellfun(@(x)x~=0,a),2),:);
OR
out = a(all(cell2mat(a) ~= 0,2),:);
  1 comentario
Chin
Chin el 14 de Feb. de 2012
I would like to know if my cell array is a = [{0} {2} {3}; {0} {4} {5}; {0} {7} {3}], how do i delete the column that contains all of 0? thanks again.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Multidimensional 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