Merge Options

版本 1.1.0.0 (1.8 KB) 作者: Matthew Kelly
Merge a struct of default options with a struct of user options
102.0 次下载
更新时间 2016/1/19

查看许可证

% output = mergeOptions(default, user, name)
%
% Merge a default options struct with a user-defined options struct. Works
% recursively, and will issue warning messages if the user attempts to
% define a field that is not in the default options.
%
% BEHAVIOR:
%
% - All fields in DEFAULT will be present in OUTPUT
% - If a field is in both DEFAULT and USER, then the value from USER is
% present in OUTPUT
% - If a field is present in USER, but not DEFAULT, then issue a warning.
% - Applies recursively
%
%
% NOTES:
%
% The argument NAME is optional, and contains a string specifying the
% name of the options struct. This is primarily used for printing
% warnings to the user.
%
% This function works recursively. For example, if there is a struct
% inside of a struct, then it will recursively apply this merge.
%

引用格式

Matthew Kelly (2024). Merge Options (https://www.mathworks.com/matlabcentral/fileexchange/54837-merge-options), MATLAB Central File Exchange. 检索来源 .

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

启发作品: Particle Swarm Optimization

Community Treasure Hunt

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

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

Bug Fix: old version was not properly overwriting default values in sub-structs.

1.0.0.0