how to delete zeros from a matrix
    5 vues (au cours des 30 derniers jours)
  
       Afficher commentaires plus anciens
    
hi there,
say i have a matrix: set1 =
     1     3
     0     0
     1     5
     0     0
     1     8
     0     0
     1    16
how do i get rid of the zero rows, so it looks like:set1 =
     1     3
     1     5
     1     8
     1    16
tnx
SN
0 commentaires
Réponse acceptée
  Image Analyst
      
      
 le 18 Fév 2013
        Try this:
m = [...
  1     3
     0     0
     1     5
     0     0
     1     8
     0     0
     1    16]
   zeroRows = ~all(m, 2)
   m(zeroRows,:) = []
0 commentaires
Plus de réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

