0001 function o = add_item(o, item_name, item_contents)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 if nargin < 2
0012 error('Need item name to add');
0013 end
0014 if nargin < 3
0015 item_contents = [];
0016 end
0017 I = default_item(o);
0018 if isempty(item_contents)
0019 item_contents = I;
0020 else
0021 def_fns = fieldnames(I);
0022 new_fns = def_fns(~ismember(def_fns, fieldnames(item_contents)));
0023 for fn = new_fns'
0024 item_contents = setfield(item_contents, fn{1}, getfield(I, fn{1}));
0025 end
0026 end
0027 o = set_item_struct(o, item_name, item_contents);