<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/239462</link>
    <title>MATLAB Central Newsreader - how many times repeat a number in an array??</title>
    <description>Feed for thread: how many times repeat a number in an array??</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>Mon, 30 Mar 2009 02:27:01 -0400</pubDate>
      <title>Re: how many times repeat a number in an array??</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/239462#638558</link>
      <author>Hoi Wong</author>
      <description>&quot;Roger Stafford&quot; &amp;lt;ellieandrogerxyzzy@mindspring.com.invalid&amp;gt; wrote in message &amp;lt;gg1jpt$eja$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &quot;Maria &quot; &amp;lt;mariaki16@hotmail.com&amp;gt; wrote in message &amp;lt;gg1cbq$9gl$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; what inputs doi have to put in accumarray and in histc in the histc help i found this:&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; N = HISTC(X,EDGES), for vector X, counts the number of values in X&lt;br&gt;
&amp;gt; &amp;gt;     that fall between the elements in the EDGES vector (which must contain&lt;br&gt;
&amp;gt; &amp;gt;     monotonically non-decreasing values).  N is a LENGTH(EDGES) vector&lt;br&gt;
&amp;gt; &amp;gt;     containing these counts. &lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; what the eges should be???&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;   Maria, I will answer your questions this way.  If you make a careful study of what the matlab functions 'histc' and/or 'accumarray' are intended to accomplish, then you will almost automatically realize what kind of inputs they require to solve your particular problem.  This will probably require some experimentation on your part in the use of those functions in order to attain such an understanding.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;   This is the way one best learns to use Matlab.  Being given complete solutions without such an understanding is definitely NOT the right way since it leaves one unprepared for other problems.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Roger Stafford&lt;br&gt;
&lt;br&gt;
Thanks Roger! I've never given that much thought to the extended parameters for find(), sort() and a 5-argument use for sparse() though I've been using them for a while (sparse is quite new to me though. I'm developing a sparse_cell class/dataType and jengaMatrix is a piece of the puzzle)&lt;br&gt;
&lt;br&gt;
My first algorithm was embarassing.......it's complicated, uses cellfun, sum, and runs 100000 times slower than any of yours, and it does not work for non-unique deletion list. Turns out that your 8-line solution is the fastest of all as I expected (because they are all built-in functions). Simple test is the matrix mentioned in my first post, and the second data set was captured from my project.&lt;br&gt;
&lt;br&gt;
Here's the link to all of your algorithms and mine as well. jengaMatrixSpeedTest tests them all and generate the report below:&lt;br&gt;
&lt;br&gt;
Does all algorithm give the same result for the simple test? true&lt;br&gt;
---------------------------------------------------------------&lt;br&gt;
Is the test matrices cardinal? true&lt;br&gt;
Cardinality preserved? true&lt;br&gt;
Is the deletion list unique? false&lt;br&gt;
Roger:  0.00110589&lt;br&gt;
Bruno1: 0.00870681&lt;br&gt;
Bruno2: 0.02111930&lt;br&gt;
Bruno4: 0.00462781&lt;br&gt;
Bruno5: 0.00282878&lt;br&gt;
Does all algorithm give the same result for the stress test (with non-unique deletion items)? true&lt;br&gt;
Cardinality preserved? true&lt;br&gt;
---------------------------------------------------------------&lt;br&gt;
Hoi:  110.50091451&lt;br&gt;
Roger:  0.00098781&lt;br&gt;
Bruno1: 0.00648331&lt;br&gt;
Bruno2: 0.00672234&lt;br&gt;
Bruno4: 0.00160589&lt;br&gt;
Bruno5: 0.00117171&lt;br&gt;
Does all algorithm give the same result for the stress test (with unique deletion items)? true&lt;br&gt;
Cardinality preserved? true</description>
    </item>
    <item>
      <pubDate>Mon, 30 Mar 2009 02:32:01 -0400</pubDate>
      <title>Re: how many times repeat a number in an array??</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/239462#638560</link>
      <author>Hoi Wong</author>
      <description>&quot;Hoi Wong&quot; &amp;lt;wonghoi.ee@gmailNOSPAM.com&amp;gt; wrote in message &amp;lt;gqpall$2g8$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &quot;Roger Stafford&quot; &amp;lt;ellieandrogerxyzzy@mindspring.com.invalid&amp;gt; wrote in message &amp;lt;gg1jpt$eja$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; &quot;Maria &quot; &amp;lt;mariaki16@hotmail.com&amp;gt; wrote in message &amp;lt;gg1cbq$9gl$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; what inputs doi have to put in accumarray and in histc in the histc help i found this:&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; N = HISTC(X,EDGES), for vector X, counts the number of values in X&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt;     that fall between the elements in the EDGES vector (which must contain&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt;     monotonically non-decreasing values).  N is a LENGTH(EDGES) vector&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt;     containing these counts. &lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; what the eges should be???&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt;   Maria, I will answer your questions this way.  If you make a careful study of what the matlab functions 'histc' and/or 'accumarray' are intended to accomplish, then you will almost automatically realize what kind of inputs they require to solve your particular problem.  This will probably require some experimentation on your part in the use of those functions in order to attain such an understanding.&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt;   This is the way one best learns to use Matlab.  Being given complete solutions without such an understanding is definitely NOT the right way since it leaves one unprepared for other problems.&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; Roger Stafford&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Thanks Roger! I've never given that much thought to the extended parameters for find(), sort() and a 5-argument use for sparse() though I've been using them for a while (sparse is quite new to me though. I'm developing a sparse_cell class/dataType and jengaMatrix is a piece of the puzzle)&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; My first algorithm was embarassing.......it's complicated, uses cellfun, sum, and runs 100000 times slower than any of yours, and it does not work for non-unique deletion list. Turns out that your 8-line solution is the fastest of all as I expected (because they are all built-in functions). Simple test is the matrix mentioned in my first post, and the second data set was captured from my project.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Here's the link to all of your algorithms and mine as well. jengaMatrixSpeedTest tests them all and generate the report below:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Does all algorithm give the same result for the simple test? true&lt;br&gt;
&amp;gt; ---------------------------------------------------------------&lt;br&gt;
&amp;gt; Is the test matrices cardinal? true&lt;br&gt;
&amp;gt; Cardinality preserved? true&lt;br&gt;
&amp;gt; Is the deletion list unique? false&lt;br&gt;
&amp;gt; Roger:  0.00110589&lt;br&gt;
&amp;gt; Bruno1: 0.00870681&lt;br&gt;
&amp;gt; Bruno2: 0.02111930&lt;br&gt;
&amp;gt; Bruno4: 0.00462781&lt;br&gt;
&amp;gt; Bruno5: 0.00282878&lt;br&gt;
&amp;gt; Does all algorithm give the same result for the stress test (with non-unique deletion items)? true&lt;br&gt;
&amp;gt; Cardinality preserved? true&lt;br&gt;
&amp;gt; ---------------------------------------------------------------&lt;br&gt;
&amp;gt; Hoi:  110.50091451&lt;br&gt;
&amp;gt; Roger:  0.00098781&lt;br&gt;
&amp;gt; Bruno1: 0.00648331&lt;br&gt;
&amp;gt; Bruno2: 0.00672234&lt;br&gt;
&amp;gt; Bruno4: 0.00160589&lt;br&gt;
&amp;gt; Bruno5: 0.00117171&lt;br&gt;
&amp;gt; Does all algorithm give the same result for the stress test (with unique deletion items)? true&lt;br&gt;
&amp;gt; Cardinality preserved? true&lt;br&gt;
&lt;br&gt;
Oops....sorry. I replied to the wrong thread</description>
    </item>
    <item>
      <pubDate>Wed, 19 Nov 2008 01:29:02 -0500</pubDate>
      <title>how many times repeat a number in an array??</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/239462#611697</link>
      <author>Maria </author>
      <description>i have a function that gets from the user a random Array.by using the unique function i have a unique list with the arguments of the vector.with out using loop how do i find the times which a number is repeat in the array&lt;br&gt;
&lt;br&gt;
Any help??</description>
    </item>
    <item>
      <pubDate>Wed, 19 Nov 2008 01:51:02 -0500</pubDate>
      <title>Re: how many times repeat a number in an array??</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/239462#611701</link>
      <author>Roger Stafford</author>
      <description>&quot;Maria &quot; &amp;lt;mariaki16@hotmail.com&amp;gt; wrote in message &amp;lt;gfvq4u$goe$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; i have a function that gets from the user a random Array.by using the unique function i have a unique list with the arguments of the vector.with out using loop how do i find the times which a number is repeat in the array&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Any help??&lt;br&gt;
&lt;br&gt;
Check on the function 'histc'.&lt;br&gt;
&lt;br&gt;
Roger Stafford</description>
    </item>
    <item>
      <pubDate>Wed, 19 Nov 2008 02:19:02 -0500</pubDate>
      <title>Re: how many times repeat a number in an array??</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/239462#611705</link>
      <author>Maria </author>
      <description>can you explane me little the srtucture of histc becouse i don't understand it from the help ?</description>
    </item>
    <item>
      <pubDate>Wed, 19 Nov 2008 02:48:01 -0500</pubDate>
      <title>Re: how many times repeat a number in an array??</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/239462#611708</link>
      <author>Roger Stafford</author>
      <description>&quot;Maria &quot; &amp;lt;mariaki16@hotmail.com&amp;gt; wrote in message &amp;lt;gfvt2m$hmp$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; can you explane me little the srtucture of histc becouse i don't understand it from the help ?&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;Hint: What interesting use can you make of the monotonically increasing output of 'unique'?&lt;br&gt;
&lt;br&gt;
Roger Stafford</description>
    </item>
    <item>
      <pubDate>Wed, 19 Nov 2008 04:00:04 -0500</pubDate>
      <title>Re: how many times repeat a number in an array??</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/239462#611715</link>
      <author>Roger Stafford</author>
      <description>&quot;Maria &quot; &amp;lt;mariaki16@hotmail.com&amp;gt; wrote in message &amp;lt;gfvq4u$goe$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; i have a function that gets from the user a random Array.by using the unique function i have a unique list with the arguments of the vector.with out using loop how do i find the times which a number is repeat in the array&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Any help??&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;An alternative and possbily superior hint is to use the third output argument of 'unique' in the 'accumarray' function rather than doing 'histc'.  This has the advantage of requiring only one sort operation altogether.&lt;br&gt;
&lt;br&gt;
Roger Stafford</description>
    </item>
    <item>
      <pubDate>Wed, 19 Nov 2008 15:46:02 -0500</pubDate>
      <title>Re: how many times repeat a number in an array??</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/239462#611824</link>
      <author>Maria </author>
      <description>&quot;Roger Stafford&quot; &amp;lt;ellieandrogerxyzzy@mindspring.com.invalid&amp;gt; wrote in message &amp;lt;gg0304$g8i$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &quot;Maria &quot; &amp;lt;mariaki16@hotmail.com&amp;gt; wrote in message &amp;lt;gfvq4u$goe$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; i have a function that gets from the user a random Array.by using the unique function i have a unique list with the arguments of the vector.with out using loop how do i find the times which a number is repeat in the array&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; Any help??&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;   An alternative and possbily superior hint is to use the third output argument of 'unique' in the 'accumarray' function rather than doing 'histc'.  This has the advantage of requiring only one sort operation altogether.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Roger Stafford&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
what inputs doi have to put in accumarray and in histc in the histc help i found this:&lt;br&gt;
&lt;br&gt;
N = HISTC(X,EDGES), for vector X, counts the number of values in X&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;that fall between the elements in the EDGES vector (which must contain&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;monotonically non-decreasing values).  N is a LENGTH(EDGES) vector&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;containing these counts. &lt;br&gt;
&lt;br&gt;
what the eges should be???</description>
    </item>
    <item>
      <pubDate>Wed, 19 Nov 2008 17:53:01 -0500</pubDate>
      <title>Re: how many times repeat a number in an array??</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/239462#611859</link>
      <author>Roger Stafford</author>
      <description>&quot;Maria &quot; &amp;lt;mariaki16@hotmail.com&amp;gt; wrote in message &amp;lt;gg1cbq$9gl$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; what inputs doi have to put in accumarray and in histc in the histc help i found this:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; N = HISTC(X,EDGES), for vector X, counts the number of values in X&lt;br&gt;
&amp;gt;     that fall between the elements in the EDGES vector (which must contain&lt;br&gt;
&amp;gt;     monotonically non-decreasing values).  N is a LENGTH(EDGES) vector&lt;br&gt;
&amp;gt;     containing these counts. &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; what the eges should be???&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;Maria, I will answer your questions this way.  If you make a careful study of what the matlab functions 'histc' and/or 'accumarray' are intended to accomplish, then you will almost automatically realize what kind of inputs they require to solve your particular problem.  This will probably require some experimentation on your part in the use of those functions in order to attain such an understanding.&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;This is the way one best learns to use Matlab.  Being given complete solutions without such an understanding is definitely NOT the right way since it leaves one unprepared for other problems.&lt;br&gt;
&lt;br&gt;
Roger Stafford</description>
    </item>
  </channel>
</rss>

