<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Reordering Arrays</title>
	<atom:link href="http://blogs.mathworks.com/loren/2007/02/16/reordering-arrays/feed/" rel="self" type="application/rss+xml" />
	<link>http://blogs.mathworks.com/loren/2007/02/16/reordering-arrays/</link>
	<description>Loren Shure works on design of the MATLAB language at MathWorks. She writes here about once a week on MATLAB programming and related topics.</description>
	<lastBuildDate>Thu, 09 Feb 2012 04:19:21 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Navaneethan Santhanam</title>
		<link>http://blogs.mathworks.com/loren/2007/02/16/reordering-arrays/#comment-29606</link>
		<dc:creator>Navaneethan Santhanam</dc:creator>
		<pubDate>Mon, 21 Jul 2008 15:35:58 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/?p=77#comment-29606</guid>
		<description>Thanks a lot, Loren! That worked perfectly.</description>
		<content:encoded><![CDATA[<p>Thanks a lot, Loren! That worked perfectly.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Loren</title>
		<link>http://blogs.mathworks.com/loren/2007/02/16/reordering-arrays/#comment-29595</link>
		<dc:creator>Loren</dc:creator>
		<pubDate>Wed, 16 Jul 2008 20:16:48 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/?p=77#comment-29595</guid>
		<description>Use the values as indices into A.

&lt;pre&gt;&lt;code&gt;
A = [1.2 3.8 5.7 90 63.7 88.65]
n = randperm(length(A))
ind = n(1:3)
B=A(ind)
&lt;/code&gt;&lt;/pre&gt;

--Loren</description>
		<content:encoded><![CDATA[<p>Use the values as indices into A.</p>
<pre><code>
A = [1.2 3.8 5.7 90 63.7 88.65]
n = randperm(length(A))
ind = n(1:3)
B=A(ind)
</code></pre>
<p>&#8211;Loren</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Navaneethan Santhanam</title>
		<link>http://blogs.mathworks.com/loren/2007/02/16/reordering-arrays/#comment-29594</link>
		<dc:creator>Navaneethan Santhanam</dc:creator>
		<pubDate>Wed, 16 Jul 2008 20:14:07 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/?p=77#comment-29594</guid>
		<description>Loren,

Thank you for the prompt response! I tried your idea out. However, randperm works only on integers, and consequently all values in the vector n are approximated to the nearest integer. Any other thoughts?

Navaneethan</description>
		<content:encoded><![CDATA[<p>Loren,</p>
<p>Thank you for the prompt response! I tried your idea out. However, randperm works only on integers, and consequently all values in the vector n are approximated to the nearest integer. Any other thoughts?</p>
<p>Navaneethan</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Loren</title>
		<link>http://blogs.mathworks.com/loren/2007/02/16/reordering-arrays/#comment-29593</link>
		<dc:creator>Loren</dc:creator>
		<pubDate>Wed, 16 Jul 2008 19:48:51 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/?p=77#comment-29593</guid>
		<description>Navaneethan-

Take a look at the function randperm.  I think it will do what you need.  Something like this:

&lt;pre&gt;&lt;code&gt;
A = [1.2 3.8 5.7 90 63.7 88.65]
n = randperm(length(A))
ind = n(1:3)
&lt;/code&gt;
&lt;/pre&gt;

and repeat the last 2 lines as often as you need.

--Loren</description>
		<content:encoded><![CDATA[<p>Navaneethan-</p>
<p>Take a look at the function randperm.  I think it will do what you need.  Something like this:</p>
<pre><code>
A = [1.2 3.8 5.7 90 63.7 88.65]
n = randperm(length(A))
ind = n(1:3)
</code>
</pre>
<p>and repeat the last 2 lines as often as you need.</p>
<p>&#8211;Loren</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Navaneethan Santhanam</title>
		<link>http://blogs.mathworks.com/loren/2007/02/16/reordering-arrays/#comment-29592</link>
		<dc:creator>Navaneethan Santhanam</dc:creator>
		<pubDate>Wed, 16 Jul 2008 19:38:33 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/?p=77#comment-29592</guid>
		<description>Loren,

I&#039;m trying to run a simulation in which a vector needs to be reordered randomly during each iteration of the simulation. I&#039;ve looked up MATLAB&#039;s help documentation, and can&#039;t seem to find anything.

To give you an example:
A = [1.2 3.8 5.7 90 63.7 88.65] and I need to pick 3 numbers from the array randomly without replacement. I&#039;d like to randomly reorder the array and pick the first 3 each time. Is there a built-in function to accomplish the randomising part? Also, is this the most efficient way to do it?

Navaneethan</description>
		<content:encoded><![CDATA[<p>Loren,</p>
<p>I&#8217;m trying to run a simulation in which a vector needs to be reordered randomly during each iteration of the simulation. I&#8217;ve looked up MATLAB&#8217;s help documentation, and can&#8217;t seem to find anything.</p>
<p>To give you an example:<br />
A = [1.2 3.8 5.7 90 63.7 88.65] and I need to pick 3 numbers from the array randomly without replacement. I&#8217;d like to randomly reorder the array and pick the first 3 each time. Is there a built-in function to accomplish the randomising part? Also, is this the most efficient way to do it?</p>
<p>Navaneethan</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Loren</title>
		<link>http://blogs.mathworks.com/loren/2007/02/16/reordering-arrays/#comment-16073</link>
		<dc:creator>Loren</dc:creator>
		<pubDate>Tue, 20 Feb 2007 16:57:34 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/?p=77#comment-16073</guid>
		<description>Dan-

The flipping will work if the data came from nchoosek.  It won&#039;t always work.  I&#039;m just trying to point people to various tools.

--Loren</description>
		<content:encoded><![CDATA[<p>Dan-</p>
<p>The flipping will work if the data came from nchoosek.  It won&#8217;t always work.  I&#8217;m just trying to point people to various tools.</p>
<p>&#8211;Loren</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dan K</title>
		<link>http://blogs.mathworks.com/loren/2007/02/16/reordering-arrays/#comment-16072</link>
		<dc:creator>Dan K</dc:creator>
		<pubDate>Tue, 20 Feb 2007 16:36:39 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/?p=77#comment-16072</guid>
		<description>Loren,
To make sure I am understanding.  This analysis will then only work in the specific case where the rows are already in order, just backwards.  These approaches don&#039;t act to order the data in terms of lowest high value first, that was already done (albeit backwards) by nchoosek.  Is this correct?
Dan</description>
		<content:encoded><![CDATA[<p>Loren,<br />
To make sure I am understanding.  This analysis will then only work in the specific case where the rows are already in order, just backwards.  These approaches don&#8217;t act to order the data in terms of lowest high value first, that was already done (albeit backwards) by nchoosek.  Is this correct?<br />
Dan</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Loren</title>
		<link>http://blogs.mathworks.com/loren/2007/02/16/reordering-arrays/#comment-16071</link>
		<dc:creator>Loren</dc:creator>
		<pubDate>Tue, 20 Feb 2007 16:11:47 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/?p=77#comment-16071</guid>
		<description>Dan-

Flipping IS reordering.  It&#039;s not deeper than that.

--Loren</description>
		<content:encoded><![CDATA[<p>Dan-</p>
<p>Flipping IS reordering.  It&#8217;s not deeper than that.</p>
<p>&#8211;Loren</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dan K</title>
		<link>http://blogs.mathworks.com/loren/2007/02/16/reordering-arrays/#comment-16070</link>
		<dc:creator>Dan K</dc:creator>
		<pubDate>Tue, 20 Feb 2007 15:57:05 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/?p=77#comment-16070</guid>
		<description>Hi Loren,
I&#039;m mightily confused as to how using rot90 is sorting the array so that the cards with the lowest high value are coming up first.  Doesn&#039;t rot90(X,2) just flip the array by 180 degrees, preserving the order of the rows?  Likewise the flip-flip method seems to do the same thing.  Where is the re-ordering occurring?
-Dan</description>
		<content:encoded><![CDATA[<p>Hi Loren,<br />
I&#8217;m mightily confused as to how using rot90 is sorting the array so that the cards with the lowest high value are coming up first.  Doesn&#8217;t rot90(X,2) just flip the array by 180 degrees, preserving the order of the rows?  Likewise the flip-flip method seems to do the same thing.  Where is the re-ordering occurring?<br />
-Dan</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Loren</title>
		<link>http://blogs.mathworks.com/loren/2007/02/16/reordering-arrays/#comment-16065</link>
		<dc:creator>Loren</dc:creator>
		<pubDate>Mon, 19 Feb 2007 20:25:25 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/?p=77#comment-16065</guid>
		<description>Steve-

Good catch and sorry about that.  I have updated the blog to show the right version now.

--Loren</description>
		<content:encoded><![CDATA[<p>Steve-</p>
<p>Good catch and sorry about that.  I have updated the blog to show the right version now.</p>
<p>&#8211;Loren</p>
]]></content:encoded>
	</item>
</channel>
</rss>

