Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: cell arrays and structs
Date: Sun, 9 Aug 2009 16:38:01 +0000 (UTC)
Organization: Universit&#228;tsSpital Z&#252;rich
Lines: 24
Message-ID: <h5mu19$lof$1@fred.mathworks.com>
References: <a2f1b899-3886-492b-adb0-9530210f6315@g19g2000vbi.googlegroups.com> <see-82000A.08402409082009@news.frontiernet.net>
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 1249835881 22287 172.30.248.37 (9 Aug 2009 16:38:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sun, 9 Aug 2009 16:38:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 11
Xref: news.mathworks.com comp.soft-sys.matlab:561946


Doug Schwarz <see@sig.for.address.edu> wrote in message <see-82000A.08402409082009@news.frontiernet.net>...
> In article 
> <a2f1b899-3886-492b-adb0-9530210f6315@g19g2000vbi.googlegroups.com>,
>  David <david.b.a.epstein@googlemail.com> wrote:
> > I have a 380x1 cell array fPN. Each cell has class 'char' and contains
> > a string.
> > I also have a 380x1 cell array ta. Each cell has class 'struct'. For
> > example I get
> > >> ta{5}
> > ans =
> >         num: '1'
> > My question is: Is there an array method to add to each ta{i} a new
> > field whose value will be the string in fPN{i}, or should I just give
> > up and loop through the cells, adding the new field one by one?

> Yes, suppose you want to use the field name 'string', then
>   [ta.string] = fPN{:};
> will do it if your version of MATLAB is new enough.

no - does not work...
according to the OP's spec, his/her TAs are CELLs of STRUCTs - and not just STRUCTs...
hence, a simple for loop is probably the fastest solution...

us