defaults.m

版本 1.0.0.0 (1.9 KB) 作者: jl
Utility function to simplify setting default values for variables in functions.
308.0 次下载
更新时间 2014/7/30

查看许可证

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);

引用格式

jl (2024). defaults.m (https://www.mathworks.com/matlabcentral/fileexchange/47394-defaults-m), MATLAB Central File Exchange. 检索时间: .

MATLAB 版本兼容性
创建方式 R2011a
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 Argument Definitions 的更多信息
标签 添加标签

Community Treasure Hunt

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

Start Hunting!
版本 已发布 发行说明
1.0.0.0