From help-octave-request at bevo dot che dot wisc dot edu Sun Feb 1 07:58:44 2004 Subject: Re: varargout form a DLD function From: Paul Kienzle To: Shai Ayal Cc: Geraint Paul Bevan , help-octave Date: Sun, 1 Feb 2004 08:54:21 -0500 No, you should be returning a cell array. Lists are deprecated. I don't have the syntax memorized, but it should be something like: Cell x(5,1); x(1) = 1; ... retval(0) = x; return retval; Paul Kienzle pkienzle at users dot sf dot net On Feb 1, 2004, at 8:51 AM, Shai Ayal wrote: > Essentially you suggest returning a list for the function. This is a > nice trick which solves my problem completely > > Thanks for the help > > Shai > > Geraint Paul Bevan wrote: >> -----BEGIN PGP SIGNED MESSAGE----- >> Hash: SHA1 >> Shai Ayal wrote on 01/29/04 22:10: >> | Hi all, >> | >> | I am trying to return a variable number of arguments from a DLD >> function >> | >> | >> | however, I cannot recover these arguments at the command line: >> | >> | Note that if I know the number of arguments I can get them as in >> line 4. >> | but what if I don't know beforehand ? Is there something similar to >> | varargin{:} for output arguments ? >> | >> | Shai >> | >> You can return a variable number of arguments by returning an >> octave_value_list as the first element of retval: >> ~/test: >> $ cat varargouttest.cc >> #include >> DEFUN_DLD (varargouttest, args, nargout, "") >> { >> octave_value_list retval, retval2; >> for (int i = 4; i >= 0; i--) { >> retval2(i) = octave_value (1 + i); >> } >> retval(0) = retval2; >> nargout = 5; >> return retval; >> } >> ~/test: >> $ mkoctfile varargouttest.cc >> ~/test: >> $ octave -q >> octave:1> varargouttest >> ans = >> ( >> ~ [1] = 1 >> ~ [2] = 2 >> ~ [3] = 3 >> ~ [4] = 4 >> ~ [5] = 5 >> ) >> octave:2> >> -----BEGIN PGP SIGNATURE----- >> Version: GnuPG v1.2.2 (GNU/Linux) >> iEYEARECAAYFAkAZNV8ACgkQcXV3N50QmNMEpQCeJaBEFPh/HYp4A3z7oOUOPAsi >> RYgAn2qQ2c6/CJNeAgBbXDa/Ai/WqCjP >> =5JaE >> -----END PGP SIGNATURE----- >> ------------------------------------------------------------- >> 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 >> ------------------------------------------------------------- > ------------------------------------------------------------- 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 -------------------------------------------------------------