<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/159861</link>
    <title>MATLAB Central Newsreader - Bug in mat2cell?</title>
    <description>Feed for thread: Bug in mat2cell?</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>Sun, 25 Nov 2007 10:48:03 -0500</pubDate>
      <title>Bug in mat2cell?</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/159861#402963</link>
      <author>Bruno Luong</author>
      <description>Hello&lt;br&gt;
&lt;br&gt;
X=rand(2,2,2);&lt;br&gt;
C=mat2cell(X,2,[1 1],[1 1]);&lt;br&gt;
&lt;br&gt;
The last instruction produces the following error message,&lt;br&gt;
which I think is a bug.&lt;br&gt;
&lt;br&gt;
??? Index exceeds matrix dimensions.&lt;br&gt;
&lt;br&gt;
Error in ==&amp;gt; mat2cell at 227&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;c{cind} = x(tref{:});&lt;br&gt;
&lt;br&gt;
My MATLAB version is 7.3.0.267 (R2006b).&lt;br&gt;
&lt;br&gt;
Comments?&lt;br&gt;
&lt;br&gt;
Bruno</description>
    </item>
    <item>
      <pubDate>Sun, 25 Nov 2007 11:30:51 -0500</pubDate>
      <title>Re: Bug in mat2cell?</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/159861#402965</link>
      <author>Bruno Luong</author>
      <description>See above</description>
    </item>
    <item>
      <pubDate>Sun, 25 Nov 2007 12:16:14 -0500</pubDate>
      <title>Re: Bug in mat2cell?</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/159861#402967</link>
      <author>Bruno Luong</author>
      <description>I look at the Mathworks's mat2cell code, and at the line&lt;br&gt;
#198, the array ref is updated under certain condition:&lt;br&gt;
&lt;br&gt;
...&lt;br&gt;
if (inc~=1) &amp;&amp; ~(cellsize(1)==1)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[ref{1:inc-1}] = deal(refstart{1:inc-1});&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;refstatic(1:inc-1) = 0;&lt;br&gt;
end&lt;br&gt;
...&lt;br&gt;
&lt;br&gt;
The condition ~(cellsize(1)==1) seems to cause the Bug. If I&lt;br&gt;
remove it from the test, as following:&lt;br&gt;
&lt;br&gt;
...&lt;br&gt;
if (inc~=1)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[ref{1:inc-1}] = deal(refstart{1:inc-1});&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;refstatic(1:inc-1) = 0;&lt;br&gt;
end&lt;br&gt;
...&lt;br&gt;
&lt;br&gt;
it works. I'm not sure what is the test on cellsize(1) is&lt;br&gt;
for, and I'm not sure I would introduce a mess in mat2cell&lt;br&gt;
function by removing it. Hope someone at mathworks could&lt;br&gt;
answer the question.&lt;br&gt;
&lt;br&gt;
Bruno</description>
    </item>
    <item>
      <pubDate>Sun, 25 Nov 2007 20:38:49 -0500</pubDate>
      <title>Re: Bug in mat2cell?</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/159861#402996</link>
      <author>roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)</author>
      <description>In article &amp;lt;fibjt3$64b$1@fred.mathworks.com&amp;gt;,&lt;br&gt;
Bruno Luong &amp;lt;brunoluong@yahoo.com&amp;gt; wrote:&lt;br&gt;
&lt;br&gt;
&amp;gt;X=rand(2,2,2);&lt;br&gt;
&amp;gt;C=mat2cell(X,2,[1 1],[1 1]);&lt;br&gt;
&lt;br&gt;
&amp;gt;The last instruction produces the following error message,&lt;br&gt;
&amp;gt;which I think is a bug.&lt;br&gt;
&lt;br&gt;
&amp;gt;??? Index exceeds matrix dimensions.&lt;br&gt;
&lt;br&gt;
&amp;gt;My MATLAB version is 7.3.0.267 (R2006b).&lt;br&gt;
&lt;br&gt;
No error is produced in R2007a.&lt;br&gt;
-- &lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&quot;Okay, buzzwords only. Two syllables, tops.&quot;  -- Laurie Anderson</description>
    </item>
    <item>
      <pubDate>Sun, 25 Nov 2007 22:11:21 -0500</pubDate>
      <title>Re: Bug in mat2cell?</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/159861#403008</link>
      <author>Bruno Luong</author>
      <description>roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson) wrote in message &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; No error is produced in R2007a.&lt;br&gt;
&lt;br&gt;
Thanks!</description>
    </item>
    <item>
      <pubDate>Mon, 26 Nov 2007 09:04:29 -0500</pubDate>
      <title>Re: Bug in mat2cell?</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/159861#403063</link>
      <author>Bruno Luong</author>
      <description>&quot;Bruno Luong&quot; &amp;lt;brunoluong@yahoo.com&amp;gt; wrote in message&lt;br&gt;
&amp;lt;fibp2d$sff$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; I look at the Mathworks's mat2cell code, and at the line&lt;br&gt;
&amp;gt; #198, the array ref is updated under certain condition:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; ...&lt;br&gt;
&amp;gt; if (inc~=1) &amp;&amp; ~(cellsize(1)==1)&lt;br&gt;
&amp;gt;     [ref{1:inc-1}] = deal(refstart{1:inc-1});&lt;br&gt;
&amp;gt;     refstatic(1:inc-1) = 0;&lt;br&gt;
&amp;gt; end&lt;br&gt;
&amp;gt; ...&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; The condition ~(cellsize(1)==1) seems to cause the Bug. If I&lt;br&gt;
&amp;gt; remove it from the test, as following:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; ...&lt;br&gt;
&amp;gt; if (inc~=1)&lt;br&gt;
&amp;gt;     [ref{1:inc-1}] = deal(refstart{1:inc-1});&lt;br&gt;
&amp;gt;     refstatic(1:inc-1) = 0;&lt;br&gt;
&amp;gt; end&lt;br&gt;
&amp;gt; ...&lt;br&gt;
&amp;gt; &lt;br&gt;
&lt;br&gt;
Ditto, the test ~(cellsize(1)==1) is removed from the source&lt;br&gt;
code of mat2cell in R2007b.&lt;br&gt;
&lt;br&gt;
It seems to be a right fix for customer who still own older&lt;br&gt;
version of MATLAB. I would expect Mathwork would react to my&lt;br&gt;
question, but they seem to ignore it.&lt;br&gt;
&lt;br&gt;
Bruno</description>
    </item>
  </channel>
</rss>

