Path: news.mathworks.com!not-for-mail
From: "Anthony Hopf" <anthony.hopf@gmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Removing rows containing all zeros in a matrix
Date: Tue, 13 Jul 2010 18:04:04 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 44
Message-ID: <i1i9qj$o2e$1@fred.mathworks.com>
References: <hs1pti$hmk$1@fred.mathworks.com> <hs1qg9$psa$1@fred.mathworks.com>
Reply-To: "Anthony Hopf" <anthony.hopf@gmail.com>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1279044244 24654 172.30.248.35 (13 Jul 2010 18:04:04 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 13 Jul 2010 18:04:04 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1899184
Xref: news.mathworks.com comp.soft-sys.matlab:652782

us,  very cool. If you want to get rid of any row that has 0's in it

m =

     1     2     3
     0     4     5
     0     0     0
     6     0     0

>> m(any(m==0,2),:)=[]

m =

     1     2     3



"us " <us@neurol.unizh.ch> wrote in message <hs1qg9$psa$1@fred.mathworks.com>...
> "Rahul Singhal" <rsinghalomatic@gmail.com> wrote in message <hs1pti$hmk$1@fred.mathworks.com>...
> > Hi All,
> >    I have a matrix containing 1's and 0's. I want to remove the rows that contain all 0's. Is there any matlab function that can do this.
> > 
> > Can anybody help me in this.
> > 
> > Thanks 
> > Rahul Singhal
> 
> one of the solutions
> 
   m=[
           1 2 3
         0 4 5
          0 0 0
           6 0 0
      ];
>      m(all(m==0,2),:)=[]
> %{
> %    m =
>      1     2     3
>      0     4     5
>      6     0     0
> %
> 
> us