[Scilab-users] Accessing the nth output of a function

Jan-Åge Langeland j-lan at online.no
Mon Jan 11 14:03:04 CET 2016


On 11.01.2016 09:26, Dang Ngoc Chan, Christophe wrote:
> function [n,  varargout] = foo()
>    varargout = list(1, 2, 3, 4);
>    n = argn(1);
> endfunction
>
> [N, L] = foo()
>
> Disp(L)
It looks like in this case output arguments are not variable but limited 
to 2 (one single element and one list), so varargout  works like any 
other variable. In Scilab 6.0 it would make sense to swap the output 
arguments:
   function [varargout, n] = foo()
        varargout = list(1, 2, 3, 4);
        n = argn(1);
   endfunction

as this would allow using the elements directly in an expression like this:
LL=foo()(3)^foo()(2)

Or just put everything in the list and forget about varargout:
   function [al] = fal(varargin)
       al = list( 1, 2, 3, 4, [argn(1),argn(2)]);
   endfunction

inarguments=fal(7,8,9)($)(2)

JÅ





More information about the users mailing list