help-octave
[Top][All Lists]
Advanced

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

Re: Forcing Variable Outputs


From: Geordie McBain
Subject: Re: Forcing Variable Outputs
Date: Wed, 29 Mar 2006 12:20:46 +1000

Does this do what you want?

  function varargout = fxn1 (varargin)
    varargout = fxn2 (varargin{:});
  endfunction

  function varargout = fxn2 (varargin)
    varargout = {varargin};
  endfunction

I see:

octave2.9:1> a = fxn1 (1)
a = 1
octave2.9:2> [a, b] = fxn1 (1, 2)
a = 1
b = 2


On Tue, 2006-03-28 at 20:53 -0500, Bill Denney wrote:
> I have a function that I want to force to have a variable number of output 
> arguements based on its calling function's number of output arguements. 
> In other words, I want to do something like
> 
> function [varargout] = fxn1(varargin)
> 
>    varargout{:} = fxn2(varargin{:});
> 
> endfunction
> 
> and I want fxn2 to see the same number of output arguements that fxn1 
> sees.
> 
> I thought of initializing varargout like
> 
> varargout = cell(1, nargout);
> 
> but that didn't work.  Is there a way to do this?
> 
> Bill
> 



-------------------------------------------------------------
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
-------------------------------------------------------------



reply via email to

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