📄 write_structure.m
字号:
function dummy = write_structure(st,args)
% WRITE Store a value to the location pointed to by a STRUCTURE object.
%
% WRITE(st,val,member) - writes the value VAL to the STRUCTURE member specified by MEMBER.
%
% WRITE(st,val,member,varargin) - writes the value VAL to the STRUCTURE member specified
% by member, where VARARGIN are extra WRITE options. See WRITE options of MEMBER.
%
% WRITE(st,index,val,member) - writes the value VAL to the STRUCTURE member of the STRUCTURE
% element INDEX.
%
% WRITE(st,index,val,member,varargin) - writes the value VAL to the STRUCTURE member of the STRUCTURE
% element INDEX, where VARARGIN are extra WRITE options. See WRITE options of MEMBER.
%
% Copyright 2002 The MathWorks, Inc.
% $Revision: 1.12 $ $Date: 2002/05/30 15:34:51 $
error(nargchk(2,2,nargin));
if ~ishandle(st),
error('First parameter must be a STRUCTURE handle ');
end
nargs = length(args);
if isempty(args),
error('Not enough input arguments.');
elseif ischar(args{1}),
if nargs<2,
error('Incorrect number of inputs, please specify the member name. ');
end
struct_idx = ones(1,length(st.size));
extra_args = args;
elseif isnumeric(args{1}),
nargs = nargs-1;
if nargs<2,
error('Incorrect number of inputs, please include the value. ');
end
if any(round(args{1})<=0),
error(['Invalid STRUCTURE index: [' num2str(args{1}) '] ']);
elseif isempty(args{1}),
struct_idx = ones(1,length(st.size));
else
struct_idx = args{1};
end
extra_args = {args{2:end}};
else
error('Second Parameter must be a STRUCTURE index or a STRUCTURE membername.');
end
if mod(nargs,2)~=0
error(['WRITE requires member name and value arguments to be specified in pairs.']);
end
if ~iscellstr({extra_args{1:2:nargs-1}})
error(['WRITE requires member name and value arguments to be specified in pairs.']);
end
for i=1:2:nargs-1
name = extra_args{i};
value = extra_args{i+1};
membobj = getmember(st,struct_idx,name);
write(membobj,value);
end
% [EOF] write_structure.m
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -