Scilab Home page | Wiki | Bug tracker | Forge | Mailing list archives | ATOMS | File exchange
Please login or create an account
Change language to: Français - Português - 日本語 - Русский
Scilab Help >> Advanced functions > varargout


arbitrarily long list of output arguments


A function whose output argument list ends with varargout may be called with more output arguments than indicated in the output argument list. The Left-Hand-Side output arguments passed at calling time from the varargout keyword onwards are extracted out of the varargout list defined in the function.

varargout = function ex() may be called with any number of output arguments. Within function ex output arguments may be stored in varargout(i).

[X1,...,Xn,varargout] = function ex() may also be used. In this case the Xi variables must be assigned in the function as well as varargout(i).

argn(1) returns the actual total number of output arguments.

varargout is by default initialized to list().


function varargout=exampl()
    varargout = list(1,2,3,4)

x = exampl()
[x, y]    = exampl()
[x, y, z] = exampl()

function [a, b, varargout]=exampl1()
    a = 'first'
    b = 'second'
    varargout = list(1,2,3,4)

[a, b]  = exampl1()
[a,b,c] = exampl1()

See also

  • argn — Returns the actual number of input/output arguments in a function call
  • function — opens a function definition
  • list — a Scilab object and a list definition function
  • varargin — variable number of arguments in an input argument list


6.0.0 varargout is now initialized to list() by default.
Scilab Enterprises
Copyright (c) 2011-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Tue Jul 20 11:10:45 CEST 2021