Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Binary Matrix Manipulation
Date: Wed, 21 Jul 2010 06:52:03 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 2
Message-ID: <i265ej$aqv$1@fred.mathworks.com>
Reply-To: <HIDDEN>
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 1279695123 11103 172.30.248.38 (21 Jul 2010 06:52:03 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 21 Jul 2010 06:52:03 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1833358
Xref: news.mathworks.com comp.soft-sys.matlab:654810

I want to find the first occurrence of 1 in each row of a  binary matrix and convert all other elements to 0 AND convert all elements to the right of 1 to one. For example.
A = [0 0 0 1; 1 0 0 1; 0 0 0 0; 0 1 0 0]. Then I want two matrices: A1 = [ 0 0 0 1; 1 0 0 0; 0 0 0 0; 0 1 0 0] and A2 = [0 0 0 1; 1 1 1 1; 0 0 0 0; 0 1 1 1]. Thank you very much.