Filter löschen
Filter löschen

inputParser: How can defaults of argument x,y,... be dependent on argument a,b,...

2 Ansichten (letzte 30 Tage)
Mads
Mads am 10 Dez. 2013
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.

Antworten (0)

Kategorien

Mehr zu Argument Definitions finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by