<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Aptech &#187; Answers for "delete rows of a matrix"</title>
	<atom:link href="http://www.aptech.com/questions/delete-rows-of-a-matrix/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.aptech.com</link>
	<description></description>
	<lastBuildDate>Fri, 08 Feb 2013 19:12:28 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4.1</generator>
		<item>
		<title>By: Aptech</title>
		<link>http://www.aptech.com/questions/delete-rows-of-a-matrix/#answer-2707</link>
		<comments>http://www.aptech.com/questions/delete-rows-of-a-matrix/#answer-2707#comments</comments>
		<pubDate>Thu, 06 Dec 2012 00:42:55 +0000</pubDate>
		<dc:creator>Aptech</dc:creator>
		
		<guid isPermaLink="false">http://www.aptech.com/questions/delete-rows-of-a-matrix/#answer-2707</guid>
		<description><![CDATA[Your request will be passed on to development.]]></description>
			<content:encoded><![CDATA[<p>Your request will be passed on to development.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.aptech.com/questions/delete-rows-of-a-matrix/#answer-2707/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>By: ybao</title>
		<link>http://www.aptech.com/questions/delete-rows-of-a-matrix/#answer-2705</link>
		<comments>http://www.aptech.com/questions/delete-rows-of-a-matrix/#answer-2705#comments</comments>
		<pubDate>Wed, 05 Dec 2012 20:38:36 +0000</pubDate>
		<dc:creator>ybao</dc:creator>
		
		<guid isPermaLink="false">http://www.aptech.com/questions/delete-rows-of-a-matrix/#answer-2705</guid>
		<description><![CDATA[I was thinking about whether there is a built-in simple command. For example, indx={2,5,7}, which collects the indices of rows to be deleted from matrix A. In Matlab, this can be simply done by &#8220;A(indx,:)=[].&#8221;  The procedure provided by using &#8220;delif&#8221; &#8230; <a href="http://www.aptech.com/questions/delete-rows-of-a-matrix/#answer-2705">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I was thinking about whether there is a built-in simple command. For example, indx={2,5,7}, which collects the indices of rows to be deleted from matrix A. In Matlab, this can be simply done by &#8220;A(indx,:)=[].&#8221;  The procedure provided by using &#8220;delif&#8221; is ok (and I was using &#8220;delif&#8221;, but I hate the fact that such a simple thing should call a procedure) ; I was looking for an efficient and elegant way of achieving this.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.aptech.com/questions/delete-rows-of-a-matrix/#answer-2705/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>By: Aptech</title>
		<link>http://www.aptech.com/questions/delete-rows-of-a-matrix/#answer-2653</link>
		<comments>http://www.aptech.com/questions/delete-rows-of-a-matrix/#answer-2653#comments</comments>
		<pubDate>Tue, 04 Dec 2012 23:03:47 +0000</pubDate>
		<dc:creator>Aptech</dc:creator>
		
		<guid isPermaLink="false">http://www.aptech.com/questions/delete-rows-of-a-matrix/#answer-2653</guid>
		<description><![CDATA[How to delete selected rows of a matrix will depend upon why you would like to delete the rows. If you want to delete rows that match a specific logical expression, you would use the delif command. For example if &#8230; <a href="http://www.aptech.com/questions/delete-rows-of-a-matrix/#answer-2653">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>How to delete selected rows of a matrix will depend upon why you would like to delete the rows. If you want to delete rows that match a specific logical expression, you would use the <tt>delif</tt> command. For example if you wanted to remove all rows in which there was a negative element, you could do this:</p>
<pre>x = { -1 0,
       2 3,
       3 1,
      -4 2,
       5 9,
       6 1,
      -7 2 };
<span style="color:#009900">//Sum the rows so 'mask'</span>
<span style="color:#009900">//will be a column vector</span>
<span style="color:#009900">//with non-zeros only in rows</span>
<span style="color:#009900">//marked for deletion</span>
mask = sumr(a .< 0));

<span style="color:#009900">//Delete rows and assign new matrix to 'xout'</span>
xout = delif(x, mask);</pre>
<p>After the code above <tt>xout</tt> will equal:</p>
<pre>  
         2   3 
xout =   3   1 
         5   9 
         6   1
</pre>
<p>If you just want to delete the rows, then you could use this small procedure below.</p>
<pre>
<span style="color:#009900">//Create an additive vector from 1-10</span>
x = seqa(1, 1, 10);

<span style="color:#009900">//Rows to remove from 'x'</span>
rem = { 2, 5, 7 };
xout = delRow(x, rem);

<span style="color:#000099">proc</span> (1) = delRow(x, remove);
   <span style="color:#000099">local</span> mask, xout;
   <span style="color:#009900">//Create a vector with 1's in</span>
   <span style="color:#009900">//rows marked for deletion</span>
   <span style="color:#009900">//and zeros everywhere else</span>
   mask = zeros(rows(x), 1);
   mask[remove] = ones(rows(remove), 1);

   <span style="color:#009900">//Remove the rows and return 'xout'</span>
   xout = delif(x, mask);
   <span style="color:#000099">retp</span>(xout);
<span style="color:#000099">endp</span>;</pre>
<p>After this code above:</p>
<pre>
      1           1
      2           3
      3           4
x =   4   xout =  6
      5           8
      6           9
      7          10
      8 
      9 
     10 
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.aptech.com/questions/delete-rows-of-a-matrix/#answer-2653/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Served from: www.aptech.com @ 2013-02-09 01:43:38 --