<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/241894</link>
    <title>MATLAB Central Newsreader - find function</title>
    <description>Feed for thread: find function</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Mon, 05 Jan 2009 13:00:05 -0500</pubDate>
      <title>find function</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/241894#619892</link>
      <author>Branko </author>
      <description>Let's say that I have a random matrix:&lt;br&gt;
A=ceil(randn(10,1));&lt;br&gt;
and I want to find -1 and 2 values in the matrix. Which is done by following command&lt;br&gt;
a=find(A==-1);&lt;br&gt;
b=find(A==2);&lt;br&gt;
However I' d like to use single command which in this case is:&lt;br&gt;
c=find(A==-1 &amp; A==2);&lt;br&gt;
But I got empty matrix.Where is the cache. &lt;br&gt;
Thanks.</description>
    </item>
    <item>
      <pubDate>Mon, 05 Jan 2009 13:06:28 -0500</pubDate>
      <title>Re: find function</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/241894#619893</link>
      <author>tpl@eng.cam.ac.uk (Tim Love)</author>
      <description>&quot;Branko&quot; &amp;lt;branko_b@hotmail.com&amp;gt; writes:&lt;br&gt;
&lt;br&gt;
&amp;gt;Let's say that I have a random matrix:&lt;br&gt;
&amp;gt;A=ceil(randn(10,1));&lt;br&gt;
&amp;gt;and I want to find -1 and 2 values in the matrix. Which is done by following command&lt;br&gt;
&amp;gt;a=find(A==-1);&lt;br&gt;
&amp;gt;b=find(A==2);&lt;br&gt;
&amp;gt;However I' d like to use single command which in this case is:&lt;br&gt;
&amp;gt;c=find(A==-1 &amp; A==2);&lt;br&gt;
&amp;gt;But I got empty matrix.Where is the cache. &lt;br&gt;
The catch? You need OR, not AND, so you need | rather than &amp;</description>
    </item>
    <item>
      <pubDate>Mon, 05 Jan 2009 13:09:01 -0500</pubDate>
      <title>Re: find function</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/241894#619894</link>
      <author>Jiro Doke</author>
      <description>&quot;Branko&quot; &amp;lt;branko_b@hotmail.com&amp;gt; wrote in message &amp;lt;gjt08k$mt1$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Let's say that I have a random matrix:&lt;br&gt;
&amp;gt; A=ceil(randn(10,1));&lt;br&gt;
&amp;gt; and I want to find -1 and 2 values in the matrix. Which is done by following command&lt;br&gt;
&amp;gt; a=find(A==-1);&lt;br&gt;
&amp;gt; b=find(A==2);&lt;br&gt;
&amp;gt; However I' d like to use single command which in this case is:&lt;br&gt;
&amp;gt; c=find(A==-1 &amp; A==2);&lt;br&gt;
&amp;gt; But I got empty matrix.Where is the cache. &lt;br&gt;
&amp;gt; Thanks.&lt;br&gt;
&lt;br&gt;
That's because a number cannot be both -1 AND 2. Are you perhaps looking for either -1 OR 2?&lt;br&gt;
&lt;br&gt;
Then do&lt;br&gt;
&lt;br&gt;
c = find(A==-1 | A==2);&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
jiro</description>
    </item>
    <item>
      <pubDate>Mon, 05 Jan 2009 13:10:20 -0500</pubDate>
      <title>Re: find function</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/241894#619895</link>
      <author>us</author>
      <description>&quot;Branko&quot; &lt;br&gt;
&amp;gt; A=ceil(randn(10,1));&lt;br&gt;
&amp;gt; and I want to find -1 and 2 values in the matrix. Which is done by following command&lt;br&gt;
&amp;gt; c=find(A==-1 &amp; A==2);&lt;br&gt;
&amp;gt; But I got empty matrix.Where is the cache...&lt;br&gt;
&lt;br&gt;
one of the solutions&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;m=ceil(randn(10,1));&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;r=find(m==-1 | m==2)&lt;br&gt;
% r = 4 9 % &amp;lt;- based on random data...&lt;br&gt;
&lt;br&gt;
us</description>
    </item>
    <item>
      <pubDate>Mon, 05 Jan 2009 13:13:02 -0500</pubDate>
      <title>Re: find function</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/241894#619898</link>
      <author>Matt Fig</author>
      <description>Look at the | operator.</description>
    </item>
    <item>
      <pubDate>Tue, 06 Jan 2009 12:50:28 -0500</pubDate>
      <title>Re: find function</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/241894#620059</link>
      <author>Loren Shure</author>
      <description>In article &amp;lt;gjt08k$mt1$1@fred.mathworks.com&amp;gt;, branko_b@hotmail.com &lt;br&gt;
says...&lt;br&gt;
&amp;gt; Let's say that I have a random matrix:&lt;br&gt;
&amp;gt; A=ceil(randn(10,1));&lt;br&gt;
&amp;gt; and I want to find -1 and 2 values in the matrix. Which is done by following command&lt;br&gt;
&amp;gt; a=find(A==-1);&lt;br&gt;
&amp;gt; b=find(A==2);&lt;br&gt;
&amp;gt; However I' d like to use single command which in this case is:&lt;br&gt;
&amp;gt; c=find(A==-1 &amp; A==2);&lt;br&gt;
&amp;gt; But I got empty matrix.Where is the cache. &lt;br&gt;
&amp;gt; Thanks.&lt;br&gt;
&amp;gt; &lt;br&gt;
&lt;br&gt;
will ismember help you out?&lt;br&gt;
&lt;br&gt;
-- &lt;br&gt;
Loren&lt;br&gt;
&lt;a href=&quot;http://blogs.mathworks.com/loren&quot;&gt;http://blogs.mathworks.com/loren&lt;/a&gt;</description>
    </item>
  </channel>
</rss>

