Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Comma list with leading cell
Date: Sat, 23 May 2009 13:02:01 +0000 (UTC)
Organization: Xoran Technologies
Lines: 32
Message-ID: <gv8s49$2ua$1@fred.mathworks.com>
References: <gv8nju$kvn$1@fred.mathworks.com> <gv8r4e$19v$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1243083721 3018 172.30.248.35 (23 May 2009 13:02:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sat, 23 May 2009 13:02:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1440443
Xref: news.mathworks.com comp.soft-sys.matlab:541988


"us " <us@neurol.unizh.ch> wrote in message <gv8r4e$19v$1@fred.mathworks.com>...
> "Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <gv8nju$kvn$1@fred.mathworks.com>...
> > This syntax works it is beyond my expectation! Is it documented somewhere?
> >  
> > >> [{} 1 2 3]
> > 
> > ans = 
> > 
> >     [1]    [2]    [3]
> > 
> > % To me the correct syntax is
> > 
> > >> [{} {1 2 3}]
> > 
> > Bruno
> 
> it is a weel known fact of ML life
> 
> ...
> When MATLAB sees a subscripted assignment to an existing variable, MATLAB checks the class of the right-hand-side against the class of the left-hand-side (LHS) variable. If different, it attempts to convert the right-hand-side (RHS) variable to the type of the LHS class.
------

I'm not convinced that that explains it, since Bruno's example was not in fact an assignment (there was no LHS variable).  Also, if it were a case of a cell on the LHS converting numeric data on the RHS, the following ought to have produced the same effect

>> a={}

a = 

     {}

>> a(2:4)=[1 2 3]
??? Conversion to cell from double is not possible.