You are now following this Submission
- You will see updates in your followed content feed
- You may receive emails, depending on your communication preferences
- For input arguments x1,x2,x3, set default values x1def,x2def,x3def as a list of as parameter-value pairs using easydefaults:
easydefaults('x1',x1def,'x2',x2def,'x3',x3def);
- Defaults can be set for any input argument, whether it’s an explicit input or as part of a parameter-value pair:
function dummy_function(x,varargin)
easydefaults('x',1,'y',2);
...
end
- easydefaults and easyparse can in principle be used in either order, but it is usually better to parse first and fill in defaults after:
function dummy_function(x,varargin)
easyparse(varargin,'y')
easydefaults('x',1,'y',2);
...
end
CAVEAT UTILITOR: this function relies on evals and assignin statements. Input checking is performed to limit potential damage, but use at your own risk.
One of a series of simple functions to provide easier input parsing within MATLAB.
Cite As
Jared (2026). easydefaults (https://uk.mathworks.com/matlabcentral/fileexchange/39785-easydefaults), MATLAB Central File Exchange. Retrieved .
Acknowledgements
Inspired by: easyparse
Inspired: SETARGS | Parse user-specified optional arguments (varargin) with default values
General Information
- Version 1.3.0.0 (1.94 KB)
MATLAB Release Compatibility
- Compatible with any release
Platform Compatibility
- Windows
- macOS
- Linux
