Path: news.mathworks.com!newsfeed-00.mathworks.com!kanaga.switch.ch!switch.ch!ecngs!feeder2.ecngs.de!feeder.erje.net!feeder.eternal-september.org!eternal-september.org!not-for-mail
From: dpb <none@non.net>
Newsgroups: comp.soft-sys.matlab
Subject: Re: how to copy a submatrix fro ma matrix
Date: Tue, 03 Nov 2009 18:23:59 -0600
Organization: A noiseless patient Spider
Lines: 41
Message-ID: <hcqhso$aab$1@news.eternal-september.org>
References: <hcqep5$f8g$1@fred.mathworks.com> <hcqgbo$lnq$1@fred.mathworks.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: news.eternal-september.org U2FsdGVkX1+aqR5VL7W3eGWpIwRW/FbU2wZ9jeATqzMTyduKcOOGwLmDxlx8b5IBkirZWIEn7TaPjQLYor5ZuWJ0aKfRm1ek/m1HbQR/7n9ohzOJ4ot6KUeUXNY4NO6fNmTyPKrAvRA=
X-Complaints-To: abuse@eternal-september.org
NNTP-Posting-Date: Wed, 4 Nov 2009 00:29:13 +0000 (UTC)
In-Reply-To: <hcqgbo$lnq$1@fred.mathworks.com>
X-Auth-Sender: U2FsdGVkX188OxElewmfzWWUjRh6reGXtidafbongRM=
Cancel-Lock: sha1:ySeJLui/+JTkCHxd4tMe1ig8ITk=
User-Agent: Thunderbird 2.0.0.23 (Windows/20090812)
Xref: news.mathworks.com comp.soft-sys.matlab:582215


ade77 wrote:
...[top posting repaired...please don't do that]...
>  "Kishore " <kishore3385@yahoo.co.in> wrote in message <hcqep5$f8g$1@fred.mathworks.com>...
...
>> I would want to know if there is any command by which i can copy a
>> sub matrix from a matrix.
...
>>
>> In the above matrix, i need to copy all elements which are greater
>> than 1,to some matrix,( i.e i do no want the row 1.0e-2.....
>>
>> This can ofcourse be done in a loop,but is there any command
>> which simplifies the process? >>
>> I used bsxfun() ,but it doesnt seem to have this feature.
>>
...
 > type doc find. or help find.
 > the 'find' function will return the indicies of the elements or rows 
  > that meet your conditions.
 > Then pass the indicies back to your sub array.

Better yet, look up and read about

"logical addressing"

B=A(A>1);

Note however, your example matrix and your description of what you want 
aren't quite consonant--saving the elements >1 will eliminate at least a 
couple of entries in A that are identically one, not just the row w/ 
values <1.

If that's what you want precisely, for the sample A you would need

B=A(A>=1);

Also note that there will be a question to decide on what the shape of 
the resultant will be--the above will return a column vector which you 
can reshape() as desired if necessary.

--