From help-octave-request at bevo dot che dot wisc dot edu Thu Jan 29 10:41:00 2004 Subject: Re: varargout form a DLD function From: =?iso-8859-1?b?U/hyZW4=?= Hauberg To: Shai Ayal Cc: Help-Octave List Date: Thu, 29 Jan 2004 17:54:31 +0100 Hi I'm new to liboctave (and octave), but the way I understand it nargout tells you the number og requested output arguments. If you (in octave) do: [a b c] = test_arg() then nargout will be 3. So just change your code to: octave_value_list retval; for(int i=0;i: > Hi all, > > I am trying to return a variable number of arguments from a DLD function > > //------------------------------------------------- > #include "oct.h" > DEFUN_DLD (test_arg, args, nargout,"") > { > octave_value_list retval; > > for(int i=0;i<5;i++) retval(i)=i; > > nargout = 5; > return retval; > } > //------------------------------------------------- > > > however, I cannot recover these arguments at the command line: > > GNU Octave, version 2.1.50 (i686-pc-linux-gnu). > octave:1> test_arg() > ans = 0 > octave:2> a{:}=test_arg() > a = > { > [1,1] = 0 > } > octave:3> b=test_arg() > b = 0 > octave:4> [a,b,c]=test_arg() > a = 0 > b = 1 > c = 2 > > 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 > > -- Knibling, det gode gamle håndværk med "pinde", er rigtig kommet på mode igen ------------------------------------------------------------- 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 -------------------------------------------------------------