setParameterDefault

Simple function to set the default value for an optional function argument if omitted or empty.
197 Downloads
Updated 3 May 2011

View License

%Example:
function y = f(x,t)
setParameterDefault('x',1);
setParameterDefault('t',3);
y = 3*x-2*t;

try:
f('', 1); -> x=1 -> y = 1
f(2); -> t=3 -> y = 0
f('', []); -> x=1, t=3 -> y = -3

Cite As

Tobias Kienzler (2024). setParameterDefault (https://www.mathworks.com/matlabcentral/fileexchange/31285-setparameterdefault), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2010a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Categories
Find more on Characters and Strings in Help Center and MATLAB Answers

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.1.0.0

description improved

1.0.0.0