Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Vectorization with cell array
Date: Wed, 23 Jan 2008 15:55:03 +0000 (UTC)
Organization: Toyota Motorsport GmbH
Lines: 28
Message-ID: <fn7o0n$gvg$1@fred.mathworks.com>
References: <fn70o9$184$1@fred.mathworks.com> <fn73ei$afj$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 1201103703 17392 172.30.248.35 (23 Jan 2008 15:55:03 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 23 Jan 2008 15:55:03 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1185999
Xref: news.mathworks.com comp.soft-sys.matlab:447238



"us " <us@neurol.unizh.ch> wrote in message
<fn73ei$afj$1@fred.mathworks.com>...
> "Andrew ":
> <SNIP cell acrobatics...
> 
> one of the solutions
> 
> % the data
>      b={'first','second'};
>      c=[1,2];
> % the engine
>      clear s v; % save old stuff!
>      v=cellfun(@(a,b) {a,b},b,num2cell(c),'uni',false);
>      s=struct('f',v);
> % the result
>      s.f
> % ans = 'first' [1]
> % ans = 'second' [2]
> 
> us
Thanks but these solutions do not quite achieve what I am
looking for. In the example above v is a cell array of cell
arrays. I am looking to produce a single cell array where
v(1,1) is 'first', v(1,2)=1, v(2,1)='second' and so on. I
guess I could do [v{:}] and then reshape the output, but a
neater solution would be preferable.

Andrew