[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [OctDev] Access struct fields inside cell
From: |
Jaroslav Hajek |
Subject: |
Re: [OctDev] Access struct fields inside cell |
Date: |
Sat, 15 May 2010 07:03:14 +0200 |
On Fri, May 14, 2010 at 11:37 PM, Lukas Reichlin
<address@hidden> wrote:
> Dear Octave Community
>
> I have a struct "quaternion" with fields w, x, y and z. The fields are
> matrices.
>
> Next I build a cell array "qcell" which contains quaternions.
>
> Now I can access fields with qcell{2}.w
>
> However, qcell{:}.w doesn't seem to work.
>
> How can I extract those fields? Thanks for every help!
>
Basically, you can't. There is no simple way. Instead of building a
cell array of scalar structs, it's better to build a non-scalar
struct:
qstr = cellfun (@quaternion, varargin); # uniformoutput = true !
w = horzcat (qstr.w);
x = horzcat (qstrl.x);
y = horzcat (qstr.y);
z = horzcat (qstr.z);
--
RNDr. Jaroslav Hajek, PhD
computing expert & GNU Octave developer
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz