Deleting specific rows in a matrix
    5 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    Mohammad Juned
 el 10 de Mzo. de 2021
  
    
    
    
    
    Comentada: Mohammad Juned
 el 10 de Mzo. de 2021
               I want to delete  rows that contain element  of value 0 
for example in the following matrix B 
row 3, 4 ,5 contains a zero valued element. So I want to delete these rows and the resultant matrix would be 2*3 .
How can I remove these particular rows
   120   150   200
   250   300   350
   420   450     0
     0   100   400
   450     0   420
0 comentarios
Respuesta aceptada
  ANKUR KUMAR
      
 el 10 de Mzo. de 2021
        
      Editada: ANKUR KUMAR
      
 el 10 de Mzo. de 2021
  
      A=[120   150   200
   250   300   350
   420   450     0
     0   100   400
   450     0   420]
index=find(nanmean(A==0,2))
A(index,:)=[]
Below is the output of index and A (after removing the rows having zero value)
index =
     3
     4
     5
A =
   120   150   200
   250   300   350
4 comentarios
Más respuestas (0)
Ver también
Categorías
				Más información sobre Matrix Indexing en Help Center y File Exchange.
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

