Path: news.mathworks.com!newsfeed-00.mathworks.com!panix!bloom-beacon.mit.edu!llnews!53ab2750!not-for-mail
From: Peter Boettcher <boettcher@ll.mit.edu>
Newsgroups: comp.soft-sys.matlab
Subject: Re: find elements to include page indices
References: <g677t2$j92$1@fred.mathworks.com>
Message-ID: <muy8wvr5uic.fsf@G99-Boettcher.llan.ll.mit.edu>
Organization: MIT Lincoln Laboratory
User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/23.0.0 (gnu/linux)
Cancel-Lock: sha1:7ttb0Q/YDOdtA7PyaFO7dS5nsqs=
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Lines: 27
Date: Thu, 24 Jul 2008 08:36:27 -0400
NNTP-Posting-Host: 155.34.163.114
X-Complaints-To: news@ll.mit.edu
X-Trace: llnews 1216902242 155.34.163.114 (Thu, 24 Jul 2008 08:24:02 EDT)
NNTP-Posting-Date: Thu, 24 Jul 2008 08:24:02 EDT
Xref: news.mathworks.com comp.soft-sys.matlab:481503



"Dave Brackett" <davebrackett@hotmail.com> writes:

> "us " <us@neurol.unizh.ch> wrote in message
> <g69eo0$ntt$1@fred.mathworks.com>...
>> "Dave Brackett":
>> <SNIP simple question...
>> 
>> > ok, and then how can I find the elements of another matrix
>> > using the indices from this result...

> Ok I think i may have missed out a crucial bit of info to
> achieve what I want, so for clarity to summarise, I want to:
> 1) get the positions of non 0 values from x
> 2) use these positions to find the corresponding elements of
> b but retain their relative positions, with all other
> elements replaced by zeros.


Yes, crucial indeed.  For this to work I assume x and b are the same
size?  And to restate the question: Where the elements of x are equal to
0, set the corresponding elements of b to 0.

b(~x) = 0;

Read the section of the documentation called "Logical Indexing".

-Peter