ParseVarArgIn
Aucune licence
PARSEVARARGIN parses a parameter list. Given a set of property names, PARSEVARARGIN assigns the appropriate values to variables. The variables get the name of the property. For instance, if you call a function, foo:
foo(in,'Color','green','Charm',5);
and in foo, you call PARSEVARARGIN:
ParseVarargin({'Color','Charm','Strangeness'});
PARSEVARARGIN will create a variable Color, with the value 'green', a
variable Charm, with the value 5, and a variable Strangness, with the
value NaN.
PARSEVARARGIN will do type checking if you provide types and it will
assign NaN to parameters that are not specified.
Example
clear all;
W = 10;
in = double(rand(10,W)>.5);
XLabel = cellstr(datestr(today-[W:-1:1],'mm/dd/yy'));
Title = 'Exercise Schedule Checkerboard';
Name = 'HeartRateAnalyser';
varargin = {in,'XLabel',XLabel,'Title',Title,'Name',Name};
Prop = {'XLabel','YLabel','Title','Name'};
PClass = {'cell','cell','char','char'};
clear W in Xlabel Title
who
ParseVarargin(varargin,Prop,PClass);
clear varargin Prop PClass
who
Name
Title
XLabel
YLabel
See also varargout nargin nargout inputname function lists paren
CatOrSplitFiles CheckerboardPlot varargin nargin
assignin evalin
Key words varargout nargin nargout inputname function lists paren CatOrSplitFiles CheckerboardPlot parameter workspace assign input output arguments
It's not fancy, but it works
Citation pour cette source
Michael Robbins (2024). ParseVarArgIn (https://www.mathworks.com/matlabcentral/fileexchange/8123-parsevarargin), MATLAB Central File Exchange. Extrait(e) le .
Compatibilité avec les versions de MATLAB
Plateformes compatibles
Windows macOS LinuxCatégories
Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Découvrir Live Editor
Créez des scripts avec du code, des résultats et du texte formaté dans un même document exécutable.
Version | Publié le | Notes de version | |
---|---|---|---|
1.0.0.0 |