Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Size-function and ";"
Date: Tue, 27 Oct 2009 19:32:03 +0000 (UTC)
Organization: Battelle Energy Alliance (INL)
Lines: 36
Message-ID: <hc7hrj$ru$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>
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 1256671923 894 172.30.248.37 (27 Oct 2009 19:32:03 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 27 Oct 2009 19:32:03 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 688530
Xref: news.mathworks.com comp.soft-sys.matlab:580434

I can confirm this in 2007b.  

If the semicolon is added, but a simple

pause(.001)

is placed before the call to size, the problem disappears.  When the call to pause is removed, the incorrect size is returned.  Why should this depend on a flushing of the graphic events queue?  Something has gone afoul.   Here is the code I used, compacted a little bit:


close all, clear all
a=8e-3;   b=12*a;   nelb=4;   El=b/2*nelb;
for i=1:2*nelb+1
    sys.X(i,:)=[(i-1)*El 0.0];
end
for i=1:2*nelb+1
    sys.X=[sys.X ; [(i-1)*El 0.5]];
end
for i=1:2*nelb+1
    sys.X=[sys.X ; [(i-1)*El 1]];
end
nno=size(sys.X,1);
counter=0;
for i=1:2:2*nelb
    counter=counter+1;
    sys.T{counter}=[i i+2 nno-2*nelb+(i-1)];
end
for ii=1:2:2*nelb %Thiis entire loop seems to be disregarded by the following size-func.
    counter=counter+1;
    sys.T{counter} = [ii+2 nno-2*nelb+(ii+1) nno-2*nelb+(ii-1)]; % ";"-problem!
end
pause(.001) % comment this out to get a different value.
TT = size(sys.T,2)



Also, a whos statement can be used instead of a pause, and putting the code in a function instead of a script has no effect.