help-octave
[Top][All Lists]
Advanced

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

Re: Handling variable number of output arguments in multi-level function


From: Philip Nienhuis
Subject: Re: Handling variable number of output arguments in multi-level function calls
Date: Fri, 12 Dec 2014 14:13:30 -0800 (PST)

Jose wrote
> Hello Philip, thanks for the answer.
> 
> On 12/12/14 14:21, Philip Nienhuis wrote:
>>
>> AFAIK nargout is the most suitable way to deal with output depending on
>> the
>> number of requested output args.
> 
> Yes, that seems to be the case. I have just found
> http://stackoverflow.com/questions/4895556/how-to-wrap-a-function-using-varargin-and-varargout
> with an example of how to do it.
> 
> As a side-note, I think there is a small Matlab/Octave compatibility 
> issue here. Following the solution provided by SCFrench (who works for 

Right, so there we have "informally documented" undocumented Matlab behavior
:-)


> The MathWorks) I do the following test in Octave:
> --->
> octave:75> function varargout = wrapper( varargin )
>  > [varargout{1:nargout}] = sin( varargin{:} );
>  > endfunction
> octave:76> wrapper(0)
> octave:77> a=wrapper(0)
> a = 0
> octave:78> sin(0)
> ans = 0
> <---
> So I guess this solution does not work in Octave as in Matlab when the 
> outer-most function is called with no output arguments. I cannot 
> double-check in Matlab, as I do not have it. Can somebody please 
> confirm? If so I can then file a report.

Pic attached of what ML r2014a makes of it.
<http://octave.1599824.n4.nabble.com/file/n4667785/ml2012a_wrapper.png> 
Philip



--
View this message in context: 
http://octave.1599824.n4.nabble.com/Handling-variable-number-of-output-arguments-in-multi-level-function-calls-tp4667761p4667785.html
Sent from the Octave - General mailing list archive at Nabble.com.



reply via email to

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