parseParameters

版本 1.3.0.0 (5.4 KB) 作者: Jeffrey Chiou
Parameter name-value pair parsing - concise syntax, no assignin, and very fast.
118.0 次下载
更新时间 2016/5/12

Why do we need another parameter parsing solution? MATLAB's inputParser class, while flexible, is relatively slow. Simpler methods are verbose and/or only handle positional arguments. Many FEX parameter parsers use assignin, which is convenient, but also slow and unsafe.
This function combines brevity in usage, high performance, and the convenience and clarity of parameter name-value pairs. It is around 9-20x faster than inputParser, and is one of the fastest parameter parsers on FEX. For up-to-date documentation and bug reports, see GitHub.

Syntax:
parseParameters(Defaults, callerVarargin, varargin)

Optional inputs:
isCaseSensitive (bool): Default false. Determines case sensitivity
expandStruct (bool): Default true. If false, parseParameters returns a struct similar to the Defaults struct.

Within yourFunction(...), specify defaults in a struct:
Defaults.x = 1;
Defaults.y = 5;

Then call
[x,y] = parseParameters(Defaults,varargin);

The user can then call
yourFunction(...,'Y',2,'x',3);
to change x and y.
Note that it is case insensitive by default, and the user's order doesn't matter.

引用格式

Jeffrey Chiou (2024). parseParameters (https://github.com/jeffchiou/parseParameters), GitHub. 检索来源 .

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

参考作品: loadOptions, ArgUtils

Community Treasure Hunt

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

Start Hunting!

无法下载基于 GitHub 默认分支的版本

版本 已发布 发行说明
1.3.0.0

Description and summary reformatting/updating.

要查看或报告此来自 GitHub 的附加功能中的问题,请访问其 GitHub 仓库
要查看或报告此来自 GitHub 的附加功能中的问题,请访问其 GitHub 仓库