What does the varargin function do and what does varargin{:} mean?
    47 visualizzazioni (ultimi 30 giorni)
  
       Mostra commenti meno recenti
    
    Victoria Helm
 il 24 Giu 2020
  
    
    
    
    
    Modificato: Stephen23
      
      
 il 23 Feb 2022
            For example: [varargin{:}] = convertStringsToChars(varargin{:});
3 Commenti
  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
  Stephen23
      
      
 il 24 Giu 2020
        
      Modificato: Stephen23
      
      
 il 23 Feb 2022
  
      "What does the varargin function do..."
varargin is not a function, it is a cell array which contains any number  of optional input arguments:
"... and what does varargin{:} mean?"
That syntax creates a comma-separated list from the cell array varargin:
So your example is equivalent to this:
[varargin{1},varargin{2},..,varargin{end}] = convertStringsToChars(varargin{1},varargin{2},..,varargin{end});
0 Commenti
Più risposte (1)
  KSSV
      
      
 il 24 Giu 2020
        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.
0 Commenti
Vedere anche
Categorie
				Scopri di più su Argument Definitions in Help Center e File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



