From help-request at octave dot org Tue Mar 28 22:11:47 2006 Subject: Re: Forcing Variable Outputs From: Bill Denney To: Geordie McBain cc: help at octave dot org Date: Tue, 28 Mar 2006 23:11:31 -0500 (EST) Not exactly. As I tried that, it just gave the output as the same as the input. The problem is that I want this to work correctly (without having to do a lot of if blocks). function [varargout] = fxn1(varargin) nargin nargout varargout{:} = fxn2(varargin{:}); endfunction function [varargout] = fxn2(varargin) nargin nargout varargout = {varargin}; endfunction As it is, if I call [a b c] = fxn1(1, 2, 3) I get that nargin for fxn1 is 3, and nargin for fxn2 is 3, but nargout for fxn1 is 3 and nargout for fxn2 is 1. Bill On Wed, 29 Mar 2006, Geordie McBain wrote: > 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 >> > -- "I love America more than any other country in this world, and, exactly for this reason, I insist on the right to criticize her perpetually." -- James Baldwin ------------------------------------------------------------- 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 -------------------------------------------------------------