What does the varargin function do and what does varargin{:} mean?
Mostra commenti meno recenti
For example: [varargin{:}] = convertStringsToChars(varargin{:});
3 Commenti
varargin{:} creates a comma-separated list. On the right hand side of your example, the syntax is being used to create function call arguments. On the left hand side, it is being used to assign function return values (not concatenation, thanks Stephen!)
Stephen23
il 24 Giu 2020
This is incorrect: no arrays are being concatenated.
When used on the LHS it refers to the elements of the cell array, just like on the RHS. The only difference is that values are being assigned to those elements rather than extracted from them. This is explained in the section "Assigning to a Comma-Separated List" here:
Risposta accettata
Più risposte (1)
KSSV
il 24 Giu 2020
0 voti
varargin stands for variable number of arguments. You can input any number of arguments to the function. And these inputs are read by nargin which means the number of inputs.
Categorie
Scopri di più su Argument Definitions in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!