Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Size-function and ";"
Date: Tue, 27 Oct 2009 21:07:05 +0000 (UTC)
Organization: Universit&#228;t Heidelberg
Lines: 45
Message-ID: <hc7ndp$2mp$1@fred.mathworks.com>
References: <hc6rc3$4ji$1@fred.mathworks.com> <hc6scn$cmv$1@news.eternal-september.org> <hc7bdr$mtg$1@fred.mathworks.com> <hc7dg7$p35$1@news.eternal-september.org> <hc7hrj$ru$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1256677625 2777 172.30.248.37 (27 Oct 2009 21:07:05 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 27 Oct 2009 21:07:05 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 869888
Xref: news.mathworks.com comp.soft-sys.matlab:580449


Dear Adam!

I confirm this for Matlab 2009a.
Matlab R13 (6.5.1) works well.

I've reduced the problem again:
 
  S = [];
  counter = 0;
  for i = 1:2
     counter      = counter + 1;
     S.T{counter} = 1;
  end
  for i = 1:2
     counter      = counter + 1;
     S.T{counter} = 2;
  end
  % pause(.001) % comment this out to get a different SIZE
  % S.T{end} = 5;  % does not help
  lengthT = length(S.T);
  sizeT   = size(S.T); 
  disp(sizeT);
  disp(lengthT);
  % X = S.T;  sizeX = size(X);  % correct!

Reply:
  1 2  % This is the SIZE
  4  % This is the LENGTH, same for NUMEL

1. To my deep surprise only the SIZE is concerned, but the LENGTH is correct. NUMEL works fine, too.
2.  The order of the SIZE and LENGTH commands does not matter.
3. "disp(size(S.T))" replies the correct size!
4. Further loops can follow, but SIZE replies the same dimensions as after the first loop.
5. This bug appears for structs only. If [T] is used directly, the replies of SIZE and LENGTH are correct.
6. If [S.T] is not a cell but a vector, the problem does not appear.
7. As you can imagine, disabling the just-in-time acceleration let vanish the problem: feature('accel', 'off').
8. Using a different counter for the 2nd loop does not change the problem, e.g. counter2. Same for greater steps, e.g. counter = counter + 2;
9. Expanding [S.T] in another direction in the 2nd loop does change the problem, e.g. "S.T{counter, 2} = 2;"
10. "disp(S.T)" works well.
11. "S.T{end} = 5" inserts the 5 in the correct last position, but the reply of SIZE remains invalid.
12. A read access to [S.T] fixes the problem.

Please TWM, fix this JIT bug for as many old Matlab versions as possible.

Thanks Adam for finding this bug! Jan