<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/241001</link>
    <title>MATLAB Central Newsreader - Is there any non loop implement to find the index of a vector  in the matrix?</title>
    <description>Feed for thread: Is there any non loop implement to find the index of a vector  in the matrix?</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>Sun, 14 Dec 2008 13:29:02 -0500</pubDate>
      <title>Is there any non loop implement to find the index of a vector  in the matrix?</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/241001#616923</link>
      <author>zedong </author>
      <description>Is there any non loop implement to find the index of a vector  in the matrix?&lt;br&gt;
for example:&lt;br&gt;
a=[1 2]&lt;br&gt;
b=[4 5;6 7;8 7;1 2;2 3]&lt;br&gt;
I want to return  4&lt;br&gt;
(which is the index of a in b)&lt;br&gt;
Thank you !</description>
    </item>
    <item>
      <pubDate>Sun, 14 Dec 2008 13:39:02 -0500</pubDate>
      <title>Re: Is there any non loop implement to find the index of a vector  in the matrix?</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/241001#616925</link>
      <author>zedong </author>
      <description>example 2:&lt;br&gt;
a=[1 2;5 4]&lt;br&gt;
&amp;nbsp;b=[4 5;6 7;8 7;1 2;2 3]&lt;br&gt;
I want to return  [4;1]&lt;br&gt;
(I think [4 5] is the same as [5 4])</description>
    </item>
    <item>
      <pubDate>Sun, 14 Dec 2008 13:49:02 -0500</pubDate>
      <title>Re: Is there any non loop implement to find the index of a vector  in the matrix?</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/241001#616928</link>
      <author>Florian </author>
      <description>How about this:&lt;br&gt;
&lt;br&gt;
a=[1 2];&lt;br&gt;
b=[4 5;6 7;8 7;1 2;2 3];&lt;br&gt;
%return the row index where theres the number you are searching for&lt;br&gt;
firstcolumnrow=find(b(:,1)==a(1,1))&lt;br&gt;
secondcolumnrow=find(b(:,2)==a(1,2))&lt;br&gt;
&lt;br&gt;
if firstcolumnrow and seconcolumnrow are equal this is the row that you are searching for&lt;br&gt;
&lt;br&gt;
&quot;zedong &lt;br&gt;
&quot; &amp;lt;zdongwu@gmail.com&amp;gt; wrote in message &amp;lt;gi31mu$sqn$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Is there any non loop implement to find the index of a vector  in the matrix?&lt;br&gt;
&amp;gt; for example:&lt;br&gt;
&amp;gt; a=[1 2]&lt;br&gt;
&amp;gt; b=[4 5;6 7;8 7;1 2;2 3]&lt;br&gt;
&amp;gt; I want to return  4&lt;br&gt;
&amp;gt; (which is the index of a in b)&lt;br&gt;
&amp;gt; Thank you !</description>
    </item>
    <item>
      <pubDate>Sun, 14 Dec 2008 15:05:04 -0500</pubDate>
      <title>Re: Is there any non loop implement to find the index of a vector  in the matrix?</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/241001#616942</link>
      <author>hailiang shen</author>
      <description>you can change the matrix to a 'char', and use 'findstr' function.&lt;br&gt;
&lt;br&gt;
For example, &lt;br&gt;
a=num2str([1, 2]);&lt;br&gt;
b=num2str(reshape([4 5;6 7;8 7;1 2;2 3]', 1, 10);&lt;br&gt;
findstr(b,a)&lt;br&gt;
&lt;br&gt;
&quot;zedong &lt;br&gt;
&quot; &amp;lt;zdongwu@gmail.com&amp;gt; wrote in message &amp;lt;gi31mu$sqn$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Is there any non loop implement to find the index of a vector  in the matrix?&lt;br&gt;
&amp;gt; for example:&lt;br&gt;
&amp;gt; a=[1 2]&lt;br&gt;
&amp;gt; b=[4 5;6 7;8 7;1 2;2 3]&lt;br&gt;
&amp;gt; I want to return  4&lt;br&gt;
&amp;gt; (which is the index of a in b)&lt;br&gt;
&amp;gt; Thank you !</description>
    </item>
    <item>
      <pubDate>Sun, 14 Dec 2008 15:21:02 -0500</pubDate>
      <title>Re: Is there any non loop implement to find the index of a vector  in the matrix?</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/241001#616948</link>
      <author>us</author>
      <description>&quot;zedong&quot;&lt;br&gt;
&amp;gt; Is there any non loop implement to find the index of a vector  in the matrix?&lt;br&gt;
&amp;gt; for example:&lt;br&gt;
&amp;gt; a=[1 2]&lt;br&gt;
&amp;gt; b=[4 5;6 7;8 7;1 2;2 3]&lt;br&gt;
&amp;gt; I want to return  4&lt;br&gt;
&lt;br&gt;
one of the solutions&lt;br&gt;
&lt;br&gt;
% the data&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;a=[&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;1,2 % &amp;lt;- pos 4&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;4,5 % &amp;lt;- pos 1&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;];&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;b=[4 5;6 7;8 7;1 2;2 3];&lt;br&gt;
% the engine&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[ix,ix]=ismember(a,b,'rows');&lt;br&gt;
% the result&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ix&lt;br&gt;
%{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ix =&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;4&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;1&lt;br&gt;
%}&lt;br&gt;
&lt;br&gt;
us</description>
    </item>
    <item>
      <pubDate>Sun, 14 Dec 2008 15:53:02 -0500</pubDate>
      <title>Re: Is there any non loop implement to find the index of a vector  in the matrix?</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/241001#616959</link>
      <author>zedong </author>
      <description>&quot;us &quot; &amp;lt;us@neurol.unizh.ch&amp;gt; wrote in message &amp;lt;gi388u$ed0$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &quot;zedong&quot;&lt;br&gt;
&amp;gt; &amp;gt; Is there any non loop implement to find the index of a vector  in the matrix?&lt;br&gt;
&amp;gt; &amp;gt; for example:&lt;br&gt;
&amp;gt; &amp;gt; a=[1 2]&lt;br&gt;
&amp;gt; &amp;gt; b=[4 5;6 7;8 7;1 2;2 3]&lt;br&gt;
&amp;gt; &amp;gt; I want to return  4&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; one of the solutions&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; % the data&lt;br&gt;
&amp;gt;      a=[&lt;br&gt;
&amp;gt;           1,2 % &amp;lt;- pos 4&lt;br&gt;
&amp;gt;           4,5 % &amp;lt;- pos 1&lt;br&gt;
&amp;gt;      ];&lt;br&gt;
&amp;gt;      b=[4 5;6 7;8 7;1 2;2 3];&lt;br&gt;
&amp;gt; % the engine&lt;br&gt;
&amp;gt;      [ix,ix]=ismember(a,b,'rows');&lt;br&gt;
&amp;gt; % the result&lt;br&gt;
&amp;gt;      ix&lt;br&gt;
&amp;gt; %{&lt;br&gt;
&amp;gt;      ix =&lt;br&gt;
&amp;gt;           4&lt;br&gt;
&amp;gt;           1&lt;br&gt;
&amp;gt; %}&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; us&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
Thank you very much.you have done a wonderful work.Thank you</description>
    </item>
    <item>
      <pubDate>Sun, 14 Dec 2008 18:04:02 -0500</pubDate>
      <title>Re: Is there any non loop implement to find the index of a vector  in the matrix?</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/241001#616985</link>
      <author>Roger Stafford</author>
      <description>&quot;zedong &lt;br&gt;
&quot; &amp;lt;zdongwu@gmail.com&amp;gt; wrote in message &amp;lt;gi3a4u$r0s$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &quot;us &quot; &amp;lt;us@neurol.unizh.ch&amp;gt; wrote in message &amp;lt;gi388u$ed0$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; .....&lt;br&gt;
&amp;gt; &amp;gt;      [ix,ix]=ismember(a,b,'rows');&lt;br&gt;
&amp;gt; ......&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;I believe you will need to sort the rows of a and b before using Urs's 'ismember' technique, if you want such rows as [4,5] and [5,4] to be regarded as identical:&lt;br&gt;
&lt;br&gt;
&amp;nbsp;[ix,ix]=ismember(sort(a,2),sort(b,2),'rows');&lt;br&gt;
&lt;br&gt;
Roger Stafford</description>
    </item>
  </channel>
</rss>

