defaults.m
Version 1.0.0.0 (1.92 KB) by
jl
Utility function to simplify setting default values for variables in functions.
Syntax:
DEFAULTS('Variable',Value)
Problem:
Usually in a function call:
out = function(Var1, Var2)
if (~exist('Var1','var')
Var1 = 1234;
end
if (~exist('Var2','var')
Var2 = 3456;
end
This gets tedious after a while.
Solution using DEFAULTS
out = function(Var1, Var2)
defaults('Var1',1234,'Var2',3456);
Cite As
jl (2026). defaults.m (https://ch.mathworks.com/matlabcentral/fileexchange/47394-defaults-m), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Created with
R2011a
Compatible with any release
Platform Compatibility
Windows macOS LinuxCategories
Find more on Argument Definitions in Help Center and MATLAB Answers
Tags
Acknowledgements
Inspired: image segmentation, edge detection with parametrique filter DKl
Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
| Version | Published | Release Notes | |
|---|---|---|---|
| 1.0.0.0 |
