<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/266804</link>
    <title>MATLAB Central Newsreader - Stumped on a Matrix Analysis</title>
    <description>Feed for thread: Stumped on a Matrix Analysis</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>Wed, 25 Nov 2009 12:12:03 -0500</pubDate>
      <title>Stumped on a Matrix Analysis</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/266804#697379</link>
      <author>gozer </author>
      <description>I am a novice and stumped with what may be a simple problem but not sure how to attack.  I have a matrix A=m x n and a smaller matrix filterA=[2:6,21,34,35:43].  I would like to return a matrix B that contains all rows of A whose value in col 'n'  matches a value in filterA.&lt;br&gt;
I have looked at 'filter', 'sort', sortrows, 'ismember' and others but none seem to be the right thing.  Even tried multiple if-thens but that got messy quickly.</description>
    </item>
    <item>
      <pubDate>Wed, 25 Nov 2009 12:56:19 -0500</pubDate>
      <title>Re: Stumped on a Matrix Analysis</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/266804#697397</link>
      <author>Jos (10584) </author>
      <description>&quot;gozer &quot; &amp;lt;wolfeb@timken.com&amp;gt; wrote in message &amp;lt;hej6uj$hqq$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; I am a novice and stumped with what may be a simple problem but not sure how to attack.  I have a matrix A=m x n and a smaller matrix filterA=[2:6,21,34,35:43].  I would like to return a matrix B that contains all rows of A whose value in col 'n'  matches a value in filterA.&lt;br&gt;
&amp;gt; I have looked at 'filter', 'sort', sortrows, 'ismember' and others but none seem to be the right thing.  Even tried multiple if-thens but that got messy quickly.&lt;br&gt;
&lt;br&gt;
From your description I think your after this (a small example might have help here!)&lt;br&gt;
&lt;br&gt;
% data&lt;br&gt;
&amp;nbsp;&amp;nbsp;A = [ 1 2 3 ; 2 3 4 ; 1 3 4 ; 2 1 5 ; 2 4 3 ; 3 1 3] ; % arbitrary m-by-n array&lt;br&gt;
&amp;nbsp;&amp;nbsp;filterA = [3 4] ;&lt;br&gt;
&lt;br&gt;
% task: keep only those rows in A for which the last element is present in &quot;filterA&quot;&lt;br&gt;
% engine (can be written in a one-liner)&lt;br&gt;
&amp;nbsp;&amp;nbsp;Col_n_of_A = A(:,end) ; % n-th, i.e. last column of A&lt;br&gt;
&amp;nbsp;&amp;nbsp;tf = ismember(Col_n_of_A, filterA) ; &lt;br&gt;
&amp;nbsp;&amp;nbsp;B = A(tf,:) &lt;br&gt;
&lt;br&gt;
hth&lt;br&gt;
Jos</description>
    </item>
    <item>
      <pubDate>Thu, 26 Nov 2009 01:22:05 -0500</pubDate>
      <title>Re: Stumped on a Matrix Analysis</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/266804#697604</link>
      <author>gozer </author>
      <description>&quot;Jos (10584) &quot; &amp;lt;#10584@fileexchange.com&amp;gt; wrote in message &amp;lt;hej9hi$qko$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &quot;gozer &quot; &amp;lt;wolfeb@timken.com&amp;gt; wrote in message &amp;lt;hej6uj$hqq$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; I am a novice and stumped with what may be a simple problem but not sure how to attack.  I have a matrix A=m x n and a smaller matrix filterA=[2:6,21,34,35:43].  I would like to return a matrix B that contains all rows of A whose value in col 'n'  matches a value in filterA.&lt;br&gt;
&amp;gt; &amp;gt; I have looked at 'filter', 'sort', sortrows, 'ismember' and others but none seem to be the right thing.  Even tried multiple if-thens but that got messy quickly.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; From your description I think your after this (a small example might have help here!)&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; % data&lt;br&gt;
&amp;gt;   A = [ 1 2 3 ; 2 3 4 ; 1 3 4 ; 2 1 5 ; 2 4 3 ; 3 1 3] ; % arbitrary m-by-n array&lt;br&gt;
&amp;gt;   filterA = [3 4] ;&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; % task: keep only those rows in A for which the last element is present in &quot;filterA&quot;&lt;br&gt;
&amp;gt; % engine (can be written in a one-liner)&lt;br&gt;
&amp;gt;   Col_n_of_A = A(:,end) ; % n-th, i.e. last column of A&lt;br&gt;
&amp;gt;   tf = ismember(Col_n_of_A, filterA) ; &lt;br&gt;
&amp;gt;   B = A(tf,:) &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; hth&lt;br&gt;
&amp;gt; Jos&lt;br&gt;
&lt;br&gt;
Jos,&lt;br&gt;
You nailed it dead on.  Code does exactly what I was looking for.  You saved me a bunch of stress.....owe  you one!&lt;br&gt;
thanks.</description>
    </item>
  </channel>
</rss>

