How do I delete a row in a matrix?
    4 visualizzazioni (ultimi 30 giorni)
  
       Mostra commenti meno recenti
    
Hi!
How would I delete all the rows that have a zero in the second column? For example, if I have the matrix
[1 3;2 0;3 11;4 8;5 0]
how could I delete the two rows containing zeroes to make my matrix look like
[1 3;3 11;4 8]
Thank you!!
0 Commenti
Risposta accettata
  James Tursa
      
      
 il 13 Mar 2015
        >> a = [1 3;2 0;3 11;4 8;5 0]
a =
     1     3
     2     0
     3    11
     4     8
     5     0
>> a(a(:,2)==0,:) = []
a =
     1     3
     3    11
     4     8
Più risposte (0)
Vedere anche
Categorie
				Scopri di più su Creating and Concatenating Matrices in Help Center e File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

