Path: news.mathworks.com!not-for-mail
From: "alan dinno" <alan_dinno@hotmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Elementary Row Operations !
Date: Fri, 28 Dec 2007 22:38:53 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 26
Message-ID: <fl3ttt$nce$1@fred.mathworks.com>
Reply-To: "alan dinno" <alan_dinno@hotmail.com>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1198881533 23950 172.30.248.35 (28 Dec 2007 22:38:53 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 28 Dec 2007 22:38:53 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1192926
Xref: news.mathworks.com comp.soft-sys.matlab:443759


Hi -

If I wanted to loop through column k in matrix A, and swap 
rows with zeros with rows without zeros, is there a faster 
way to achieve this than using multiple loops?

Example: If A=[ 20 23 5  8
                92 0  16 14
                60 0  35 88
                44 25 83 19
                44 76 74 20]

Then if I want to operate on column 2 (i.e k=2),the new A 
will should look like:
             A=[ 20 23 5  8
                 44 25 83 19
                 44 76 74 20
                 92 0  16 14 
                 60 0  35 88]

That is, the new A is the same except rows 2 and 3 of 
column 2 were interchanged with rows 4 and 5 of column 2 
because the former contained zeros.

Thanks
Alan