octave: Processing Data in Structures

 
 6.1.5 Processing Data in Structures
 -----------------------------------
 
 The simplest way to process data in a structure is within a ‘for’ loop
 (SeeLooping Over Structure Elements).  A similar effect can be
 achieved with the ‘structfun’ function, where a user defined function is
 applied to each field of the structure.  Seestructfun XREFstructfun.
 
    Alternatively, to process the data in a structure, the structure
 might be converted to another type of container before being treated.
 
  -- : C = struct2cell (S)
      Create a new cell array from the objects stored in the struct
      object.
 
      If F is the number of fields in the structure, the resulting cell
      array will have a dimension vector corresponding to ‘[F size(S)]’.
      For example:
 
           s = struct ("name", {"Peter", "Hannah", "Robert"},
                      "age", {23, 16, 3});
           c = struct2cell (s)
              ⇒ c = {2x1x3 Cell Array}
           c(1,1,:)(:)
              ⇒
                 {
                   [1,1] = Peter
                   [2,1] = Hannah
                   [3,1] = Robert
                 }
           c(2,1,:)(:)
              ⇒
                 {
                   [1,1] = 23
                   [2,1] = 16
                   [3,1] = 3
                 }
 
DONTPRINTYET       See also: Seecell2struct XREFcell2struct, *notefieldnames:
DONTPRINTYET       See also: Seecell2struct XREFcell2struct, Seefieldnames

      XREFfieldnames.