SET set an analysis object property without recording the history. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DESCRIPTION: SET set an analysis object property without recording the history. CALL: ao = setnh(ao, 'name', 'name'); ao = setnh(ao, 'provenance', provenance-object); ao = setnh(ao, 'description','description'); ao = setnh(ao, 'hist', history-object); ao = setnh(ao, 'data', data); ao = setnh(ao, 'mfile', mfile); ao = setnh(ao, 'mfilename', 'mfilename'); ao = setnh(ao, 'mdlfile', 'mdlfile'); ao = setnh(ao, 'mdlfilename','mdlfilename'); ao = setnh(ao, 'version', 'cvs-version'); ao = setnh(ao, 'created', time-object); ao = setnh(ao, plist-object); --> plist-object with key/value paies ao = setnh(ao, 'fs', fs); --> ao.data.fs = fs; ao = setnh(ao, 't0', t0); --> ao.data.t0 = t0; ao = setnh(ao, 'xunits', 'xunits'); --> ao.data.xunits = 'xunits'; ao = setnh(ao, 'yunits', 'yunits'); --> ao.data.xunits = 'yunits'; The following call returns a parameter list object that contains the default parameter values: >> pl = setnh(ao, 'Params') The following call returns a string that contains the routine CVS version: >> version = setnh(ao,'Version') The following call returns a string that contains the routine category: >> category = setnh(ao,'Category') VERSION: $Id: setnh.html,v 1.11 2008/03/31 10:27:34 hewitson Exp $ HISTORY: 30-01-07 M Hewitson Creation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0001 function aos = setnh(varargin) 0002 % SET set an analysis object property without recording the history. 0003 % 0004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0005 % 0006 % DESCRIPTION: SET set an analysis object property without recording the history. 0007 % 0008 % CALL: ao = setnh(ao, 'name', 'name'); 0009 % ao = setnh(ao, 'provenance', provenance-object); 0010 % ao = setnh(ao, 'description','description'); 0011 % ao = setnh(ao, 'hist', history-object); 0012 % ao = setnh(ao, 'data', data); 0013 % ao = setnh(ao, 'mfile', mfile); 0014 % ao = setnh(ao, 'mfilename', 'mfilename'); 0015 % ao = setnh(ao, 'mdlfile', 'mdlfile'); 0016 % ao = setnh(ao, 'mdlfilename','mdlfilename'); 0017 % ao = setnh(ao, 'version', 'cvs-version'); 0018 % ao = setnh(ao, 'created', time-object); 0019 % ao = setnh(ao, plist-object); --> plist-object with key/value paies 0020 % ao = setnh(ao, 'fs', fs); --> ao.data.fs = fs; 0021 % ao = setnh(ao, 't0', t0); --> ao.data.t0 = t0; 0022 % ao = setnh(ao, 'xunits', 'xunits'); --> ao.data.xunits = 'xunits'; 0023 % ao = setnh(ao, 'yunits', 'yunits'); --> ao.data.xunits = 'yunits'; 0024 % 0025 % The following call returns a parameter list object that contains the 0026 % default parameter values: 0027 % 0028 % >> pl = setnh(ao, 'Params') 0029 % 0030 % The following call returns a string that contains the routine CVS version: 0031 % 0032 % >> version = setnh(ao,'Version') 0033 % 0034 % The following call returns a string that contains the routine category: 0035 % 0036 % >> category = setnh(ao,'Category') 0037 % 0038 % VERSION: $Id: setnh.html,v 1.11 2008/03/31 10:27:34 hewitson Exp $ 0039 % 0040 % HISTORY: 30-01-07 M Hewitson 0041 % Creation 0042 % 0043 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0044 0045 %%% REMARK: This function don't use the generic set-function!!! 0046 0047 VERSION = '$Id: setnh.html,v 1.11 2008/03/31 10:27:34 hewitson Exp $'; 0048 CATEGORY = 'Helper'; 0049 DEFAULT_PLIST = plist('name', '', ... 0050 'data', tsdata, ... 0051 'hist', history, ... 0052 'provenance', provenance, ... 0053 'description', '', ... 0054 'mfile', {''}, ... 0055 'mfilename', '', ... 0056 'mdlfile', '', ... 0057 'mdlfilename', '', ... 0058 'plist', '', ... 0059 'version', '', ... 0060 'created', time, ... 0061 'fs', [], ... 0062 't0', time, ... 0063 'xunits', '', ... 0064 'yunits', ''); 0065 0066 %%% Check if this is a special call: default parameter list, cvs-version, 0067 if isa(varargin{1}, 'ao') && ischar(varargin{2}) 0068 in = varargin{2}; 0069 if strcmp(in, 'Params') 0070 aos = DEFAULT_PLIST; 0071 return 0072 elseif strcmp(in, 'Version') 0073 aos = VERSION; 0074 return 0075 elseif strcmp(in, 'Category') 0076 aos = CATEGORY; 0077 return 0078 end 0079 end 0080 0081 aos = []; 0082 invars = {}; 0083 pls = plist(); 0084 propArgin = {}; 0085 0086 %%% collect input ao's, plist's and ao variable names 0087 for j=1:numel(varargin) 0088 0089 if isa(varargin{j}, 'ao') 0090 aos = [aos varargin{j}]; 0091 0092 elseif isempty(propArgin) && isa(varargin{j}, 'plist') 0093 pls = [pls varargin{j}]; 0094 0095 else 0096 propArgin{end+1} = varargin{j}; 0097 end 0098 end 0099 0100 pls = combine(pls); 0101 ao_fields = fieldnames(aos); 0102 data_fields = ''; 0103 if ~isempty(aos(1).data) 0104 data_fields = fieldnames(aos(1).data); 0105 end 0106 0107 %%% Exist a plist then add the key/value pairs to propArgin 0108 if isempty(propArgin) 0109 for ii = 1:nparams(pls) 0110 %% The 'key' name of a plist/param is always stored with upper case 0111 %% characters. To set a ao property with this key we have to lower the 0112 %% 'key' characters. 0113 propArgin{end+1} = lower(pls.params(ii).key); 0114 propArgin{end+1} = pls.params(ii).val; 0115 end 0116 end 0117 0118 while length(propArgin) >= 2 0119 0120 prop = propArgin{1}; 0121 val = propArgin{2}; 0122 propArgin = propArgin(3:end); 0123 0124 %%% Normal case 0125 if ismember(prop, ao_fields) 0126 for jj = 1:numel(aos) 0127 aos(jj).(prop) = val; 0128 end 0129 0130 %%% Special case: Is prop a property of the data class then set the data class. 0131 elseif ismember(prop, data_fields) 0132 for jj = 1:numel(aos) 0133 aos(jj).data = set(aos(jj).data, prop, val); 0134 end 0135 0136 else 0137 error('### ''%s'' is not a valid %s-object property.', prop, class(aos)); 0138 end 0139 0140 end 0141 0142 if (nargout == 0) 0143 display(aos); 0144 error('\n### No output variable!\n### Please use: %s = set(%s, ''key'', ''value'');', inputname(1), inputname(1)); 0145 end 0146