help-octave
[Top][All Lists]
Advanced

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

varargout form a DLD function


From: Shai Ayal
Subject: varargout form a DLD function
Date: Fri, 30 Jan 2004 00:10:22 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6b) Gecko/20031210 Thunderbird/0.5a

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

Attachment: shaia.vcf
Description: Vcard


reply via email to

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