help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Access struct fields inside cell


From: Lukas Reichlin
Subject: Access struct fields inside cell
Date: Fri, 14 May 2010 23:37:09 +0200

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!


function q = horzcat (varargin)

  qcell = cellfun (@quaternion, varargin, "UniformOutput", false);

  w = horzcat (qcell{:}.w);
  x = horzcat (qcell{:}.x);
  y = horzcat (qcell{:}.y);
  z = horzcat (qcell{:}.z);

  q = quaternion (w, x, y, z);

endfunction


Regards
Lukas


reply via email to

[Prev in Thread] Current Thread [Next in Thread]