<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/242847</link>
    <title>MATLAB Central Newsreader - Removing specific rows from a matrix</title>
    <description>Feed for thread: Removing specific rows from a 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>Wed, 21 Jan 2009 16:59:02 -0500</pubDate>
      <title>Removing specific rows from a matrix</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/242847#623015</link>
      <author>Dominic Pompeo</author>
      <description>I have a pretty simple question, but I can't figure out the coding for it.&lt;br&gt;
&lt;br&gt;
I have a 12,300 x 12 matrix. I want to code something up that will delete rows that match up based on values in the matrix. I want it to compare the first and second row, based on the values in column one and column two and if they match I want one of the rows deleted. However, I also want it to delete rows that have the sum of columns 3:12 greater than a specified value.&lt;br&gt;
&lt;br&gt;
basically...&lt;br&gt;
&lt;br&gt;
A =&lt;br&gt;
&lt;br&gt;
...&lt;br&gt;
3.4 5.6 10 10 10 10 10 10 10 10 10 10 %row 80&lt;br&gt;
3.4 5.6 10 10 10 10 10 10 10 10 10 10 &lt;br&gt;
3.2 5.3 100 100 100 100 100 100 100 100 100 100&lt;br&gt;
...&lt;br&gt;
&lt;br&gt;
I want the code to run through each row - see that rows 80 and 81 match based on the first two values and then delete either row 80 or 81 and then see that in row 82 the sum of the last 10 columns is greater than 200 so it will delete that row also. The matching based on the first two columns will always occur consecutively if that helps with the coding. I.E the matches will always be in consecutive rows 85 &amp; 86 or 190 &amp; 191.&lt;br&gt;
&lt;br&gt;
I want the final output to just be&lt;br&gt;
&lt;br&gt;
A=&lt;br&gt;
...&lt;br&gt;
3.4 5.6 10 10 10 10 10 10 10 10 10 10 %row 80&lt;br&gt;
...&lt;br&gt;
&lt;br&gt;
Any help will be greatly appreciated. I know it may not be very clear, if anyone needs a better explanation, post and I will try my best to clear up any confusion.</description>
    </item>
    <item>
      <pubDate>Wed, 21 Jan 2009 17:32:03 -0500</pubDate>
      <title>Removing specific rows from a matrix</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/242847#623027</link>
      <author>Mohammad Monfared</author>
      <description>&quot;Dominic Pompeo&quot; &amp;lt;newbiee1987@yahoo.com&amp;gt; wrote in message &amp;lt;gl7k8m$oce$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; I have a pretty simple question, but I can't figure out the coding for it.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I have a 12,300 x 12 matrix. I want to code something up that will delete rows that match up based on values in the matrix. I want it to compare the first and second row, based on the values in column one and column two and if they match I want one of the rows deleted. However, I also want it to delete rows that have the sum of columns 3:12 greater than a specified value.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; basically...&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; A =&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; ...&lt;br&gt;
&amp;gt; 3.4 5.6 10 10 10 10 10 10 10 10 10 10 %row 80&lt;br&gt;
&amp;gt; 3.4 5.6 10 10 10 10 10 10 10 10 10 10 &lt;br&gt;
&amp;gt; 3.2 5.3 100 100 100 100 100 100 100 100 100 100&lt;br&gt;
&amp;gt; ...&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I want the code to run through each row - see that rows 80 and 81 match based on the first two values and then delete either row 80 or 81 and then see that in row 82 the sum of the last 10 columns is greater than 200 so it will delete that row also. The matching based on the first two columns will always occur consecutively if that helps with the coding. I.E the matches will always be in consecutive rows 85 &amp; 86 or 190 &amp; 191.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I want the final output to just be&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; A=&lt;br&gt;
&amp;gt; ...&lt;br&gt;
&amp;gt; 3.4 5.6 10 10 10 10 10 10 10 10 10 10 %row 80&lt;br&gt;
&amp;gt; ...&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Any help will be greatly appreciated. I know it may not be very clear, if anyone needs a better explanation, post and I will try my best to clear up any confusion.&lt;br&gt;
&lt;br&gt;
Hi,&lt;br&gt;
I think this would work:&lt;br&gt;
&lt;br&gt;
A(diff(A(:,1))==0 &amp; diff(A(:,2))==0,:)=[];&lt;br&gt;
A(sum(A(:,3:12),2)&amp;gt;200,:)=[];</description>
    </item>
  </channel>
</rss>

