Difference between revisions of "Opt args"
Jump to navigation
Jump to search
(Created page with "{{Function |name=opt_args |desc=Handles optional input arguments for functions |upd=November 2, 2012 |v=1.00 |helper=1}} <tt>'''opt_args'''</tt> is a [[L...") |
m (→Examples) |
||
| Line 15: | Line 15: | ||
==Examples== | ==Examples== | ||
| − | Please see the source code of functions such as [[PermuteSystems]] to see examples of this function in use. | + | Please see the source code of functions such as <tt>[[PermuteSystems]]</tt> to see examples of this function in use. |
Revision as of 20:05, 15 November 2012
| 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.