필터 지우기
필터 지우기

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

조회 수: 2 (최근 30일)
Mads
Mads 2013년 12월 10일
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