inputParser: How can defaults of argument x,y,... be dependent on argument a,b,...
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Say I have a function foo(X,varargin) which can do either A (X=A) or B (X=B).
If it does A then varargin should be a number of arguments, say x1, x2,.... that has certain default values (x1 = a1, x2 = a2,...), but if it does B the arguments x1, x2,.... then has other certain default values (x1 = b1, x2 = b2,...).
After initialising the p.inputParser, one uses several p.addParamValue's to check argument sanity and adds default values. Finally the arguments are compiled with p.parse(X,varargin).
In this setup how does one switch which default values to use in p.addParamValue? Put differently: Since the input arguments are not parsed until the end, how can one make a switch between (a1,a2,...) and (b1,b2,...) for X being A or B, respectively.
0 commentaires
Réponses (0)
Voir également
Catégories
En savoir plus sur Argument Definitions dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!