[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Handling variable number of output arguments in multi-level function
From: |
Jose |
Subject: |
Re: Handling variable number of output arguments in multi-level function calls |
Date: |
Fri, 12 Dec 2014 14:44:26 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 |
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
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.
Regards,
José.