[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
assign struct array to cell array
From: |
Eric Chassande-Mottin |
Subject: |
assign struct array to cell array |
Date: |
Fri, 5 Nov 2010 13:33:47 -0700 (PDT) |
hi, I'd like to assign a struct array to a cell array.
I'm wondering whether I could do that without a loop
like in this example :
clear; a=cell(3,1); b.foo=1; b(2).foo=2; b(3).foo=3; for n=1:3, a{n}=b(n);
endfor; a
a =
{
[1,1] =
{
foo = 1
}
[2,1] =
{
foo = 2
}
[3,1] =
{
foo = 3
}
}
all my attempts end up creating a cell array with three copies of b, e.g.:
clear; a=cell(3,1); b.foo=1; b(2).foo=2; b(3).foo=3; [a{:}]=deal(b(:))
I guess the reason is that b(:) isn't a cs list.
eric
--
View this message in context:
http://octave.1599824.n4.nabble.com/assign-struct-array-to-cell-array-tp3029362p3029362.html
Sent from the Octave - General mailing list archive at Nabble.com.
- assign struct array to cell array,
Eric Chassande-Mottin <=