From help-request at octave dot org Mon Apr 10 22:09:30 2006 Subject: Re: Vectors of Structures in C++ From: "John W. Eaton" To: Bill Denney Cc: help at octave dot org Date: Mon, 10 Apr 2006 23:08:01 -0400 On 10-Apr-2006, Bill Denney wrote: | function retval = TranslateSBML() | retval.b = "B"; | retval.c = makechildstruct(); | endfunction | | function retval = GetSubstruct() | for i = 1:10 | retval(i).d = i; | endfor | endfunction | | The jist of what I'm trying to do is that I want to be able to end up with | an index like | | a.c(1).d | | instead of | | a.c{1}.d | | as I currently get. Try this: #include #include #include octave_value GetSubstruct (void) { Octave_map m; Cell tmp (dim_vector (10, 1)); for (int i = 0; i < 10; i++) tmp(i) = i+1; m.assign ("d", tmp); return m; } DEFUN_DLD (TranslateSBML, , , "TranslateSBML") { Octave_map m; m.assign ("b", "B"); m.assign ("c", GetSubstruct ()); return octave_value (m); } jwe ------------------------------------------------------------- Octave is freely available under the terms of the GNU GPL. Octave's home on the web: http://www.octave.org How to fund new projects: http://www.octave.org/funding.html Subscription information: http://www.octave.org/archive.html -------------------------------------------------------------