0001 function c = set(c, varargin)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029 VERSION = '$Id: set.html,v 1.14 2008/03/31 10:27:37 hewitson Exp $';
0030 CATEGORY = 'Helper';
0031 DEFAULT_PLIST = plist('name', '', ...
0032 'x', [], ...
0033 'y', [], ...
0034 'xunits', '', ...
0035 'yunits', '', ...
0036 'version', '', ...
0037 'created', time);
0038
0039 propArgin = varargin;
0040 cdata_fields = fieldnames(c);
0041
0042
0043 if length(cdata_fields) ~= nparams(DEFAULT_PLIST)
0044 error('\n### The DEFAULT_PLIST doesn''t contain all field names of the %s-class!', class(c));
0045 end
0046
0047
0048 if ~isempty(varargin{1}) == 1 && ischar(varargin{1})
0049 in = varargin{1};
0050 if strcmp(in, 'Params')
0051 c = DEFAULT_PLIST;
0052 return
0053 elseif strcmp(in, 'Version')
0054 c = VERSION;
0055 return
0056 elseif strcmp(in, 'Category')
0057 c = CATEGORY;
0058 return
0059 end
0060 end
0061
0062 if nargin >= 2 && isa(propArgin{1}, 'plist')
0063 pl = propArgin{1};
0064 propArgin = {};
0065 for ii = 1:nparams(pl)
0066
0067
0068
0069 propArgin{end+1} = lower(pl.params(ii).key);
0070 propArgin{end+1} = pl.params(ii).val;
0071 end
0072 end
0073
0074 while length(propArgin) >= 2
0075
0076 prop = propArgin{1};
0077 val = propArgin{2};
0078 propArgin = propArgin(3:end);
0079
0080
0081 if strcmp(prop, 'vals')
0082 for jj = 1:numel(c)
0083 c(jj).y = val;
0084 end
0085
0086
0087 elseif strcmp(prop, 'tags')
0088 for jj = 1:numel(c)
0089 c(jj).x = val;
0090 end
0091
0092
0093 elseif ismember(prop, cdata_fields)
0094 for jj = 1:numel(c)
0095 c(jj).(prop) = val;
0096 end
0097 else
0098 error('### ''%s'' is not a valid %s-object property.', prop, class(c));
0099 end
0100
0101 end
0102
0103 if (nargout == 0)
0104 display(c);
0105 error('\n### No output variable!\n### Please use: %s = set(%s, ''key'', ''value'');', inputname(1), inputname(1));
0106 end