<?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: uniquely MATLAB</title>
	<atom:link href="http://blogs.mathworks.com/loren/2007/11/27/uniquely-matlab/feed/" rel="self" type="application/rss+xml" />
	<link>http://blogs.mathworks.com/loren/2007/11/27/uniquely-matlab/</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: Jim Hokanson</title>
		<link>http://blogs.mathworks.com/loren/2007/11/27/uniquely-matlab/#comment-30844</link>
		<dc:creator>Jim Hokanson</dc:creator>
		<pubDate>Sun, 22 Nov 2009 22:56:30 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/2007/11/27/uniquely-matlab/#comment-30844</guid>
		<description>Regarding D. Goodman&#039;s inquiry, I wrote a function that returns unique rows for cell arrays and posted it on file exchange just now called uniqueRows (hopefully it will post soon).  I tend to get a bit nervous about combining strings as well, especially since it is possible to artificially create non-unique values through concatenation (although perhaps somewhat unlikely) ex. -&gt; rows &#039;AC&#039;,&#039;&#039; and &#039;A&#039;,&#039;C&#039; wouldn&#039;t be unique.  The function I posted doesn&#039;t use that approach although could probably use a bit more error handling and some handling of the very issue this section brought up, returning indices

On a second note, it is good to see a suggestion for a user enhancement request.  Just the other day I was looking for a solution to what I consider to be an error in the behavior of MException.throwAsCaller with dbstop, when I stumbled across another entry from this blog, with the comment dated January of this year (see http://blogs.mathworks.com/loren/2007/04/30/a-little-bit-on-message-handling/ towards the bottom) with the author of this blog saying that she would submit an enhancement request (which I don&#039;t doubt she did).  Much to my disappointment this problem hasn&#039;t been fixed in 2009b, so I find it a bit funny and probably true the statement that the user should submit the enhancement request!</description>
		<content:encoded><![CDATA[<p>Regarding D. Goodman&#8217;s inquiry, I wrote a function that returns unique rows for cell arrays and posted it on file exchange just now called uniqueRows (hopefully it will post soon).  I tend to get a bit nervous about combining strings as well, especially since it is possible to artificially create non-unique values through concatenation (although perhaps somewhat unlikely) ex. -&gt; rows &#8216;AC&#8217;,&#8221; and &#8216;A&#8217;,'C&#8217; wouldn&#8217;t be unique.  The function I posted doesn&#8217;t use that approach although could probably use a bit more error handling and some handling of the very issue this section brought up, returning indices</p>
<p>On a second note, it is good to see a suggestion for a user enhancement request.  Just the other day I was looking for a solution to what I consider to be an error in the behavior of MException.throwAsCaller with dbstop, when I stumbled across another entry from this blog, with the comment dated January of this year (see <a href="http://blogs.mathworks.com/loren/2007/04/30/a-little-bit-on-message-handling/" rel="nofollow">http://blogs.mathworks.com/loren/2007/04/30/a-little-bit-on-message-handling/</a> towards the bottom) with the author of this blog saying that she would submit an enhancement request (which I don&#8217;t doubt she did).  Much to my disappointment this problem hasn&#8217;t been fixed in 2009b, so I find it a bit funny and probably true the statement that the user should submit the enhancement request!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Loren</title>
		<link>http://blogs.mathworks.com/loren/2007/11/27/uniquely-matlab/#comment-30331</link>
		<dc:creator>Loren</dc:creator>
		<pubDate>Mon, 18 May 2009 11:14:05 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/2007/11/27/uniquely-matlab/#comment-30331</guid>
		<description>Jerry-

You might consider using containers.Map for your indexing example.  See &lt;a href=&quot;http://blogs.mathworks.com/loren/2008/11/19/analyzing-addresses-using-different-data-structures/&quot; rel=&quot;nofollow&quot;&gt; this post&lt;/a&gt; for some examples.  Another possibility is to use the dataset array from Statistics Toolbox.  &lt;a href=&quot;http://blogs.mathworks.com/loren/2008/07/23/using-matlab-to-grade/&quot; rel=&quot;nofollow&quot;&gt;Here&#039;s&lt;/a&gt; an example.

--Loren</description>
		<content:encoded><![CDATA[<p>Jerry-</p>
<p>You might consider using containers.Map for your indexing example.  See <a href="http://blogs.mathworks.com/loren/2008/11/19/analyzing-addresses-using-different-data-structures/" rel="nofollow"> this post</a> for some examples.  Another possibility is to use the dataset array from Statistics Toolbox.  <a href="http://blogs.mathworks.com/loren/2008/07/23/using-matlab-to-grade/" rel="nofollow">Here&#8217;s</a> an example.</p>
<p>&#8211;Loren</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jerry</title>
		<link>http://blogs.mathworks.com/loren/2007/11/27/uniquely-matlab/#comment-30328</link>
		<dc:creator>Jerry</dc:creator>
		<pubDate>Sat, 16 May 2009 07:56:10 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/2007/11/27/uniquely-matlab/#comment-30328</guid>
		<description>Hi Loren,
I am not sure if this is the right place to request your suggestion in regards to the NON-NUMERIC or SYMBOLIC INDEXING in MATLAB. If not, please advise how should I submit this query for you.

I want to be able to index an array using some kind of symbolic or non-numeric indices. Let&#039;s say, 
US_states=[&#039;AL&#039;, &#039;AK&#039;, &#039;AZ&#039;, ...., &#039;WR&#039;, &#039;WY&#039;]
I want to be able to say, US_states[&#039;AK&#039;] or US_states(&#039;AK&#039;) and get 2 as answer or similaraly US_states[&#039;WY&#039;] or US_states(&#039;WY&#039;) and get 50 as answer. 

Also, if I create a 50x50 matrix of these states, say - Neighbors. where any given element in the matrix represents whether the 2 states are neighbor (basically, an adjacency matrix), I want to be able to say, Neighbors(&#039;CA&#039;,&#039;NY&#039;) and get 0 as answer, since they are not neighbors.

In nutshell, how do I implement, symbolic or non-numeric indexing in MATLAB? As you may agree, the data values are simple integers and the indices are non-numeric and if possible, I would prefer to use basic array or matrix concepts instead of cell-arrays to keep it scalable for large scale data matrices. But any or all possible approaches will be most welcome.  

Please advise. Thanks!

Sincerely,
Jerry</description>
		<content:encoded><![CDATA[<p>Hi Loren,<br />
I am not sure if this is the right place to request your suggestion in regards to the NON-NUMERIC or SYMBOLIC INDEXING in MATLAB. If not, please advise how should I submit this query for you.</p>
<p>I want to be able to index an array using some kind of symbolic or non-numeric indices. Let&#8217;s say,<br />
US_states=['AL', 'AK', 'AZ', ...., 'WR', 'WY']<br />
I want to be able to say, US_states['AK'] or US_states(&#8216;AK&#8217;) and get 2 as answer or similaraly US_states['WY'] or US_states(&#8216;WY&#8217;) and get 50 as answer. </p>
<p>Also, if I create a 50&#215;50 matrix of these states, say &#8211; Neighbors. where any given element in the matrix represents whether the 2 states are neighbor (basically, an adjacency matrix), I want to be able to say, Neighbors(&#8216;CA&#8217;,'NY&#8217;) and get 0 as answer, since they are not neighbors.</p>
<p>In nutshell, how do I implement, symbolic or non-numeric indexing in MATLAB? As you may agree, the data values are simple integers and the indices are non-numeric and if possible, I would prefer to use basic array or matrix concepts instead of cell-arrays to keep it scalable for large scale data matrices. But any or all possible approaches will be most welcome.  </p>
<p>Please advise. Thanks!</p>
<p>Sincerely,<br />
Jerry</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Loren</title>
		<link>http://blogs.mathworks.com/loren/2007/11/27/uniquely-matlab/#comment-30326</link>
		<dc:creator>Loren</dc:creator>
		<pubDate>Fri, 15 May 2009 16:37:33 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/2007/11/27/uniquely-matlab/#comment-30326</guid>
		<description>Daniel-

If you could please &lt;a href=&quot;http://www.mathworks.com/support/service_requests/contact_support.do&quot; rel=&quot;nofollow&quot;&gt;request this enhancement&lt;/a&gt; via technical support, that would be great.  It counts much more prominently if it comes from a user than if it comes from me ;-)

--Loren</description>
		<content:encoded><![CDATA[<p>Daniel-</p>
<p>If you could please <a href="http://www.mathworks.com/support/service_requests/contact_support.do" rel="nofollow">request this enhancement</a> via technical support, that would be great.  It counts much more prominently if it comes from a user than if it comes from me ;-)</p>
<p>&#8211;Loren</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel Goodman</title>
		<link>http://blogs.mathworks.com/loren/2007/11/27/uniquely-matlab/#comment-30325</link>
		<dc:creator>Daniel Goodman</dc:creator>
		<pubDate>Fri, 15 May 2009 16:14:00 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/2007/11/27/uniquely-matlab/#comment-30325</guid>
		<description>Using unique() with a combination of &#039;rows&#039; and cell arrays would be useful, and this functionality is currently unavailable. For instance, if I have:

{ &#039;thing_one&#039;, &#039;a&#039;; 
  &#039;thing_one&#039;, &#039;b&#039;;
  &#039;thing_one&#039;, &#039;b&#039;;
  &#039;thing_two&#039;, &#039;a&#039;;
  &#039;thing_two&#039;, &#039;b&#039;;
  &#039;thing_two&#039;, &#039;b&#039;;
}

and I want back the unique rows:

{ &#039;thing_one&#039;, &#039;a&#039;; 
  &#039;thing_one&#039;, &#039;b&#039;;
  &#039;thing_two&#039;, &#039;a&#039;;
  &#039;thing_two&#039;, &#039;b&#039;;
}

I cannot use unique() out of the box. 

One could get the same result by concatenating each row into one char string (also converting any numbers to chars) and then use unique(), but this seems a little dodgy.</description>
		<content:encoded><![CDATA[<p>Using unique() with a combination of &#8216;rows&#8217; and cell arrays would be useful, and this functionality is currently unavailable. For instance, if I have:</p>
<p>{ &#8216;thing_one&#8217;, &#8216;a&#8217;;<br />
  &#8216;thing_one&#8217;, &#8216;b&#8217;;<br />
  &#8216;thing_one&#8217;, &#8216;b&#8217;;<br />
  &#8216;thing_two&#8217;, &#8216;a&#8217;;<br />
  &#8216;thing_two&#8217;, &#8216;b&#8217;;<br />
  &#8216;thing_two&#8217;, &#8216;b&#8217;;<br />
}</p>
<p>and I want back the unique rows:</p>
<p>{ &#8216;thing_one&#8217;, &#8216;a&#8217;;<br />
  &#8216;thing_one&#8217;, &#8216;b&#8217;;<br />
  &#8216;thing_two&#8217;, &#8216;a&#8217;;<br />
  &#8216;thing_two&#8217;, &#8216;b&#8217;;<br />
}</p>
<p>I cannot use unique() out of the box. </p>
<p>One could get the same result by concatenating each row into one char string (also converting any numbers to chars) and then use unique(), but this seems a little dodgy.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jose Miguel</title>
		<link>http://blogs.mathworks.com/loren/2007/11/27/uniquely-matlab/#comment-30193</link>
		<dc:creator>Jose Miguel</dc:creator>
		<pubDate>Tue, 07 Apr 2009 07:28:36 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/2007/11/27/uniquely-matlab/#comment-30193</guid>
		<description>Dear Loren,

Thank you very much,
I&#039;ve posted what I&#039;ve got to the newsgroup,

Thank you very much for helping

Josemi</description>
		<content:encoded><![CDATA[<p>Dear Loren,</p>
<p>Thank you very much,<br />
I&#8217;ve posted what I&#8217;ve got to the newsgroup,</p>
<p>Thank you very much for helping</p>
<p>Josemi</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Loren</title>
		<link>http://blogs.mathworks.com/loren/2007/11/27/uniquely-matlab/#comment-30176</link>
		<dc:creator>Loren</dc:creator>
		<pubDate>Thu, 02 Apr 2009 12:52:08 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/2007/11/27/uniquely-matlab/#comment-30176</guid>
		<description>Jose Miguel-

Thanks for saying why the order matters to you.

All of the things you mention are possible.  If you are stuck, why not post what you&#039;ve got to the newsgroup: http://www.mathworks.com/matlabcentral/newsreader/
to get some ideas.

--loren</description>
		<content:encoded><![CDATA[<p>Jose Miguel-</p>
<p>Thanks for saying why the order matters to you.</p>
<p>All of the things you mention are possible.  If you are stuck, why not post what you&#8217;ve got to the newsgroup: <a href="http://www.mathworks.com/matlabcentral/newsreader/" rel="nofollow">http://www.mathworks.com/matlabcentral/newsreader/</a><br />
to get some ideas.</p>
<p>&#8211;loren</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jose Miguel</title>
		<link>http://blogs.mathworks.com/loren/2007/11/27/uniquely-matlab/#comment-30171</link>
		<dc:creator>Jose Miguel</dc:creator>
		<pubDate>Wed, 01 Apr 2009 22:28:46 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/2007/11/27/uniquely-matlab/#comment-30171</guid>
		<description>Dear Loren,

Here&#039;s an example where the order of repetitions in an array matters,
I&#039;m constantly dealing with wind data where we have about 52000 data every year (one every 10 minutes).

I always make a date vector with the help of datenum(year,month,day,hour,minute,second) so I can work with a numeric array.

When I&#039;m cleaning wind data I need to check if there are data repetitions and where (so I need to find repetitions in the date vector and know where it happens in order to remove the bad ones). I also need to find when elements in this vector don´t grow, as it should finally consist of growing elements (for example data from 2005 to 2008).

Thank you very much for your help</description>
		<content:encoded><![CDATA[<p>Dear Loren,</p>
<p>Here&#8217;s an example where the order of repetitions in an array matters,<br />
I&#8217;m constantly dealing with wind data where we have about 52000 data every year (one every 10 minutes).</p>
<p>I always make a date vector with the help of datenum(year,month,day,hour,minute,second) so I can work with a numeric array.</p>
<p>When I&#8217;m cleaning wind data I need to check if there are data repetitions and where (so I need to find repetitions in the date vector and know where it happens in order to remove the bad ones). I also need to find when elements in this vector don´t grow, as it should finally consist of growing elements (for example data from 2005 to 2008).</p>
<p>Thank you very much for your help</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sebastian Schmeier</title>
		<link>http://blogs.mathworks.com/loren/2007/11/27/uniquely-matlab/#comment-27056</link>
		<dc:creator>Sebastian Schmeier</dc:creator>
		<pubDate>Tue, 04 Mar 2008 08:39:10 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/2007/11/27/uniquely-matlab/#comment-27056</guid>
		<description>Hi Loren,

I am relatively new to Matlab or lets say I haven&#039;t used it in quite a while. I am sure that the problem that I solved here with unique can be solved most likely in a much more elegant way, but anyway.

What I have is a matrix e.g.

m = 
1 1 54
2 1 46
1 1 45
2 2 44
1 3 34
2 1 32
1 1 23
...

col 1 and 2 represents a key (that I call edge) and the 3rd col is a weight. The matrix m is ordered according to the weight. 
What I want a matrix where I have unique edges associated with the highest weight that appears in the matrix for that edge.

My approach:

% flip m to sort edges in ascending order (according to weight)
m = flipud(m);

% make unique according to edge
[b, index, index2] = unique(m(:,1:2), &#039;rows&#039;);

% attach original weights of the uniq edges
m2 = [b, m(index,3)];


Cheers,
Seb</description>
		<content:encoded><![CDATA[<p>Hi Loren,</p>
<p>I am relatively new to Matlab or lets say I haven&#8217;t used it in quite a while. I am sure that the problem that I solved here with unique can be solved most likely in a much more elegant way, but anyway.</p>
<p>What I have is a matrix e.g.</p>
<p>m =<br />
1 1 54<br />
2 1 46<br />
1 1 45<br />
2 2 44<br />
1 3 34<br />
2 1 32<br />
1 1 23<br />
&#8230;</p>
<p>col 1 and 2 represents a key (that I call edge) and the 3rd col is a weight. The matrix m is ordered according to the weight.<br />
What I want a matrix where I have unique edges associated with the highest weight that appears in the matrix for that edge.</p>
<p>My approach:</p>
<p>% flip m to sort edges in ascending order (according to weight)<br />
m = flipud(m);</p>
<p>% make unique according to edge<br />
[b, index, index2] = unique(m(:,1:2), &#8216;rows&#8217;);</p>
<p>% attach original weights of the uniq edges<br />
m2 = [b, m(index,3)];</p>
<p>Cheers,<br />
Seb</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sean Little</title>
		<link>http://blogs.mathworks.com/loren/2007/11/27/uniquely-matlab/#comment-25002</link>
		<dc:creator>Sean Little</dc:creator>
		<pubDate>Thu, 17 Jan 2008 06:47:38 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/2007/11/27/uniquely-matlab/#comment-25002</guid>
		<description>I care a lot about the order of uniqueness. There are many times when I was using previous versions of Matlab (mostly 2006a) where I would have loved to have a feature like this. Instead I would use the arrayfun command with find(...&#039;first&#039; or &#039;last&#039;).

 Explaining why I care is kind of hard, and I can&#039;t remember a good example off the top of my head. But to give a round-about explanation, one of the main reasons I use the indx output of the unique function was to apply that index to another array. It is in the other array that I care about order, where it can make a big difference which of the unique values came first.</description>
		<content:encoded><![CDATA[<p>I care a lot about the order of uniqueness. There are many times when I was using previous versions of Matlab (mostly 2006a) where I would have loved to have a feature like this. Instead I would use the arrayfun command with find(&#8230;&#8217;first&#8217; or &#8216;last&#8217;).</p>
<p> Explaining why I care is kind of hard, and I can&#8217;t remember a good example off the top of my head. But to give a round-about explanation, one of the main reasons I use the indx output of the unique function was to apply that index to another array. It is in the other array that I care about order, where it can make a big difference which of the unique values came first.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

