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 (2026). defaults.m (https://ww2.mathworks.cn/matlabcentral/fileexchange/47394-defaults-m), MATLAB Central File Exchange. 检索时间: .

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