Path: news.mathworks.com!newsfeed-00.mathworks.com!NNTP.WPI.EDU!elk.ncren.net!newsflash.concordia.ca!canopus.cc.umanitoba.ca!not-for-mail
From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Newsgroups: comp.soft-sys.matlab
Subject: Re: Vectorizing Assignment to array of structures?
Date: Fri, 9 Nov 2007 20:35:26 +0000 (UTC)
Organization: National Research Council Canada - Conseil national de rechereches Canada
Lines: 16
Message-ID: <fh2gae$eql$1@canopus.cc.umanitoba.ca>
References: <fc1m8v$b6r$1@fred.mathworks.com> <qGZEi.15770$B25.7823@news01.roc.ny> <fh2ejt$nsv$1@fred.mathworks.com>
NNTP-Posting-Host: origin.ibd.nrc.ca
X-Trace: canopus.cc.umanitoba.ca 1194640526 15189 192.70.172.160 (9 Nov 2007 20:35:26 GMT)
X-Complaints-To: abuse@cc.umanitoba.ca
NNTP-Posting-Date: Fri, 9 Nov 2007 20:35:26 +0000 (UTC)
Originator: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Xref: news.mathworks.com comp.soft-sys.matlab:436831



In article <fh2ejt$nsv$1@fred.mathworks.com>,
Lee Newman <newman.lee.nospam@comcast.net> wrote:
>> If data already exists and is the right size then use

>>    c = num2cell([5 7]);
>>    [data.mean] = c{:};

>Is there a way to do this without the intermediate
>assignment to c? [data.mean]= (num2cell(stuff)){:}  would be
>great, but Matlab doesn't allow this...

unfold = @(v) v{:};
[data.mean] = unfold(num2cell([5 7]));
-- 
   "Beware of bugs in the above code; I have only proved it correct,
   not tried it."                                    -- Donald Knuth