Path: news.mathworks.com!not-for-mail
From: Loren Shure <loren.shure@mathworks.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Empty array gets added to. (Or not)
Date: Fri, 16 Oct 2009 08:05:29 -0400
Organization: The MathWorks
Lines: 28
Message-ID: <MPG.25422b99d881778a989a39@news.mathworks.com>
References: <hb9fvj$i37$1@fred.mathworks.com>
NNTP-Posting-Host: shurel.dhcp.mathworks.com
Mime-Version: 1.0
Content-Type: text/plain; charset="iso-8859-15"
Content-Transfer-Encoding: 7bit
X-Trace: fred.mathworks.com 1255694730 16105 172.31.57.214 (16 Oct 2009 12:05:30 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 16 Oct 2009 12:05:30 +0000 (UTC)
User-Agent: MicroPlanet-Gravity/2.70.2067
Xref: news.mathworks.com comp.soft-sys.matlab:577805


In article <hb9fvj$i37$1@fred.mathworks.com>, bukwyrm@googlemail.com 
says...
> Hi.
> 
> I discovered that 
> 
> a=[];
> b=4;
> a=a+b;
> 
> will not yield an error message as would
> 
> a = a+4;
> 
> (without first assigning a). Yet it also does not give a=4... I knew that Nan+4 =NaN, but why is []+4=[] ? Is there more 'black hole beahviour' i should know about?
> 
> Thank you.
> 
> Andr
> 

b is a scalar and MATLAB addition adheres to the scalar expansion rule, 
i.e., anything + scalar is size of anything.  Hence you get empty as the 
output for a in your example.

-- 
Loren
http://blogs.mathworks.com/loren