[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Multireturn functions as arguments
From: 
John W. Eaton 
Subject: 
Multireturn functions as arguments 
Date: 
Fri, 18 Sep 1998 12:10:51 0500 (CDT) 
On 18Sep1998, (Ted Harding) <address@hidden> wrote:
 Folks, I'm trying to get my head clear  and also implement a routine 
 about the use of functions returning multiple values as arguments to
 another (wrapper) function. How can the wrapper function determine the
 number of values returned by its argument?

 As a simple example, suppose I have functions

 function [x1,x2] = F2(u) ...
 function [x1,x2,x3] = F3(u) ...

 and I want to write a single wrapper function G, to be called either as

 y = G(F2(u)) intended to be equivalent to y = G(x1,x2)

 or as

 y = G(F3(u)) intended to be equivalent to y = G(x1,x2,x3)

 where what should happen inside G depends on its nargin.
But in either of the two cases above, nargin for G will be 1.
It seems that what you really want to do is have F2 and F3 return
lists, and then have G accept a list argument and do different things
depending on the length of the list.
Unfortunately, there is no list data type in Octave 2.0.x, but there
will be one in the next major release (it is currently available in
the 2.1.x development releases).
jwe