Opt args
| opt_args | |
| Handles optional input arguments for functions | |
| Other toolboxes required | none |
|---|---|
| This is a helper function that only exists to aid other functions in QETLAB. If you are an end-user of QETLAB, you likely will never have a reason to use this function. |
opt_args is a function that provides a simple way of handling optional arguments within other functions. It reads in a cell of default values of variables and replaces them by optional argument values if those values were provided by the end-user. This reduces a check for optional arguments from what is often 8 or 9 lines of code down to 1 line of code, and also makes code easier to read. End-users of QETLAB have no reason to use this function.
Syntax
- VARARGOUT = opt_args(DEF_ARGS,EXTRA_ARG1,EXTRA_ARG2,...)
Argument descriptions
- DEF_ARGS: A cell containing default argument values. These same values will be output by opt_args unless they are overwritten by one of the optional arguments.
- EXTRA_ARGn (optional): If provided, the n-th optional argument to this function will be its n-th output argument (in place of DEF_ARGS{n}).
Examples
Please see the source code of functions such as PermuteSystems to see examples of this function in use.