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

1 次查看(过去 30 天)
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 个)

类别

Help CenterFile Exchange 中查找有关 Argument Definitions 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by