getarg

Get named argument from varargin
1.5K 次下载
更新时间 2012/3/2

查看许可证

Get named argument from varargin.
If nargout==1 returns the value. The value will be an empty cell if not found, or the default value if specified. If nargout==2, returns varargin with the argument removed, and the value.

Example:

out = doSomething( in, 'myOptionValue', 2 );

function out = doSomething( in, varargin )

%get the value specified by 'myOptionValue', return default value of 3.14 of not found.
[varargin,myOptionValue] = getarg( varargin, 'myOptionValue', 3.14 );
myOptionValue=myOptionValue{:};

%function body...

end

引用格式

Ivar Eskerud Smith (2024). getarg (https://www.mathworks.com/matlabcentral/fileexchange/35415-getarg), MATLAB Central File Exchange. 检索来源 .

MATLAB 版本兼容性
创建方式 R2011b
兼容任何版本
平台兼容性
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