<?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 "Rearrange element in vector"</title>
	<atom:link href="http://www.aptech.com/questions/rearrange-element-in-vector/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/rearrange-element-in-vector/#answer-2337</link>
		<comments>http://www.aptech.com/questions/rearrange-element-in-vector/#answer-2337#comments</comments>
		<pubDate>Mon, 05 Nov 2012 14:31:10 +0000</pubDate>
		<dc:creator>aptech</dc:creator>
		
		<guid isPermaLink="false">http://www.aptech.com/questions/rearrange-element-in-vector/#answer-2337</guid>
		<description><![CDATA[//Make v4 a missing value v4 = miss(0,0); //Reshape v4 into a 5x1 vector of missing values v4 = reshape(v4, 5, 1); //Use the same idx from the problem above v4[idx] = v1[idx]; Then the print statement: print $v4; will &#8230; <a href="http://www.aptech.com/questions/rearrange-element-in-vector/#answer-2337">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<pre>
//Make v4 a missing value
v4 = miss(0,0);

//Reshape v4 into a 5x1 vector of missing values
v4 = reshape(v4, 5, 1);

//Use the same idx from the problem above
v4[idx] = v1[idx];
</pre>
<p>Then the print statement:</p>
<pre>
print $v4;
</pre>
<p>will return:</p>
<pre>
X1 
. 
X3 
. 
X5 
`
</pre>
<p>For reference, below is the complete code snippet for both parts:</p>
<pre>
v1 = { x1, x2, x3, x4, x5 };
v2 = { x5, x3, x1 };

idx = indcv(v2, v1);

//Sort the indices
idx = sortc(idx, 1);

//Assign v3
v3 = v1[idx];

//Make v4 a missing value
v4 = miss(0,0);

//Reshape v4 into a 5x1 vector of missing values
v4 = reshape(v4, 5, 1);

v4[idx] = v1[idx];
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.aptech.com/questions/rearrange-element-in-vector/#answer-2337/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>By: yyusof</title>
		<link>http://www.aptech.com/questions/rearrange-element-in-vector/#answer-2336</link>
		<comments>http://www.aptech.com/questions/rearrange-element-in-vector/#answer-2336#comments</comments>
		<pubDate>Mon, 05 Nov 2012 01:48:45 +0000</pubDate>
		<dc:creator>yyusof</dc:creator>
		
		<guid isPermaLink="false">http://www.aptech.com/questions/rearrange-element-in-vector/#answer-2336</guid>
		<description><![CDATA[what if i want v4 to be x1 . x3 . x5 &#160;]]></description>
			<content:encoded><![CDATA[<p>what if i want v4 to be</p>
<p>x1</p>
<p>.</p>
<p>x3</p>
<p>.</p>
<p>x5</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.aptech.com/questions/rearrange-element-in-vector/#answer-2336/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>By: aptech</title>
		<link>http://www.aptech.com/questions/rearrange-element-in-vector/#answer-2334</link>
		<comments>http://www.aptech.com/questions/rearrange-element-in-vector/#answer-2334#comments</comments>
		<pubDate>Sun, 04 Nov 2012 13:21:26 +0000</pubDate>
		<dc:creator>aptech</dc:creator>
		
		<guid isPermaLink="false">http://www.aptech.com/questions/rearrange-element-in-vector/#answer-2334</guid>
		<description><![CDATA[There may be a better way to accomplish this, but you can: v1 = { x1, x2, x3, x4, x5 }; v2 = { x5, x3, x1 }; //Get the index of each element of v2's location in v1 idx &#8230; <a href="http://www.aptech.com/questions/rearrange-element-in-vector/#answer-2334">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>There may be a better way to accomplish this, but you can:</p>
<pre>
v1 = { x1, x2, x3, x4, x5 };
v2 = { x5, x3, x1 };

//Get the index of each element of v2's location in v1
idx = indcv(v2, v1);

//Sort the indices
idx = sortc(idx, 1);

//Assign v3
v3 = v1[idx];
</pre>
<p>This code will assign &#8216;v3&#8242; to be:</p>
<pre>
x1
x3
x5
</pre>
<p>You could accomplish the same action for numeric data by using the function <strong>indnv</strong> instead of <strong>indcv</strong>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.aptech.com/questions/rearrange-element-in-vector/#answer-2334/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:54:04 --