Effacer les filtres
Effacer les filtres

Remove row of cell array that contains 0.

4 vues (au cours des 30 derniers jours)
Chin
Chin le 16 Jan 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.

Réponse acceptée

Andrei Bobrov
Andrei Bobrov le 16 Jan 2012
out = a(all(cellfun(@(x)x~=0,a),2),:);
OR
out = a(all(cell2mat(a) ~= 0,2),:);
  1 commentaire
Chin
Chin le 14 Fév 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.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Multidimensional Arrays dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by