Deleting specific rows in a matrix
    6 次查看(过去 30 天)
  
       显示 更早的评论
    
   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 个评论
采纳的回答
  ANKUR KUMAR
      
 2021-3-10
        
      编辑:ANKUR KUMAR
      
 2021-3-10
  
      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
更多回答(0 个)
另请参阅
类别
				在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

