📄 assign_fields.m
字号:
function param=assign_fields(param,newparam)
% Copy fields from structure "newparam" to like-named fields of
% structure "param"
%
% Written by: E. Rietsch: October 15, 2006
% Last updated:
%
% param=assign_fields(param,newparam)
% INPUT
% param structure with fields representing default parameters
% newparam structure with fields representing new parameters
% OUTPUT
% param input structure with updated fields
% Check if the fields of newparam are a subset of those of "param"
if isempty(newparam)
return
end
fields=fieldnames(param);
newfields=fieldnames(newparam);
bool=ismember(newfields,fields);
if ~all(bool)
disp(' The following fieldes are probably misspelled:')
disp([' ',cell2str(newfields(~bool),',')])
disp(' Possible fields are:')
disp([' ',cell2str(fields,',')])
error('Abnormal termination')
end
for ii=1:length(newfields)
param.(newfields{ii})=newparam.(newfields{ii});
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -