Path: news.mathworks.com!not-for-mail
From: "Sean " <sean.dewolski@nospamplease.umit.maine.edu>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Locating matrix column that meets certain criteria
Date: Fri, 17 Sep 2010 16:26:19 +0000 (UTC)
Organization: University of Maine
Lines: 22
Message-ID: <i704rb$657$1@fred.mathworks.com>
References: <i703p5$p47$1@fred.mathworks.com> <i7046q$n9t$1@fred.mathworks.com>
Reply-To: "Sean " <sean.dewolski@nospamplease.umit.maine.edu>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1284740779 6311 172.30.248.38 (17 Sep 2010 16:26:19 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 17 Sep 2010 16:26:19 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 2256903
Xref: news.mathworks.com comp.soft-sys.matlab:670944

"Ulrik Nash" <uwn@sam.sdu.dk> wrote in message <i7046q$n9t$1@fred.mathworks.com>...
> "Ulrik Nash" <uwn@sam.sdu.dk> wrote in message <i703p5$p47$1@fred.mathworks.com>...
> > Hi Everyone,
> > 
> > Suppose I have a matrix A:
> > 
> > A = [0 0 1 0 1 1;0 0 1 1 1 1]
> > 
> > Now I wish to find that column, which not only contains all ones, but also contains no columns on its right that hold zeros. So in this case, the solution would be 5.
> > 
> > Any suggestions how I can do this neatly?
> > 
> > Regards,
> > 
> > Ulrik.
> 
> 
> 
> Should read, "but also HAS no columns on its right that hold zeros".

One way:
idx = max(find(any(~A,1)))+1