Documentation Center

  • Trial Software
  • Product Updates

Supported Index Expressions

In MATLAB®, varargin and varargout are cell arrays. Generated code does not support cell arrays, but does allow you to use the most common syntax — curly braces {} — for indexing into varargin and varargout arrays, as in this example:

%#codegen
function [x,y,z] = fcn(a,b,c)
[x,y,z] = subfcn(a,b,c);

function varargout = subfcn(varargin)
for i = 1:length(varargin)
   varargout{i} = varargin{i};
end

You can use the following index expressions. The exp arguments must be constant expressions or depend on a loop index variable.

ExpressionDescription

varargin
(read only)

varargin{exp}

Read the value of element exp

varargin{exp1: exp2}

Read the values of elements exp1 through exp2

varargin{:}

Read the values of all elements

varargout
(read and write)

varargout{exp}

Read or write the value of element exp

    Note:   The use of () is not supported for indexing into varargin and varargout arrays.

Was this topic helpful?