


SET set an analysis object property.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DESCRIPTION: SET set an analysis object property.
CALL: ao = set(ao, 'name', 'name');
ao = set(ao, 'provenance', provenance-object);
ao = set(ao, 'description','description');
ao = set(ao, 'hist', history-object);
ao = set(ao, 'data', data);
ao = set(ao, 'mfile', mfile);
ao = set(ao, 'mfilename', 'mfilename');
ao = set(ao, 'mdlfile', 'mdlfile');
ao = set(ao, 'mdlfilename','mdlfilename');
ao = set(ao, 'version', 'cvs-version');
ao = set(ao, 'created', time-object);
ao = set(ao, plist-object); --> plist-object with key/value paies
ao = set(ao, 'fs', fs); --> ao.data.fs = fs;
ao = set(ao, 't0', t0); --> ao.data.t0 = t0;
ao = set(ao, 'xunits', 'xunits'); --> ao.data.xunits = 'xunits';
ao = set(ao, 'yunits', 'yunits'); --> ao.data.xunits = 'yunits';
The following call returns a parameter list object that contains the
default parameter values:
>> pl = ao(ao, 'Params')
VERSION: $Id: set.m,v 1.22 2007/11/26 14:48:13 ingo Exp $
HISTORY: 30-01-07 M Hewitson
Creation
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


0001 function ao = set(ao, varargin) 0002 % SET set an analysis object property. 0003 % 0004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0005 % 0006 % DESCRIPTION: SET set an analysis object property. 0007 % 0008 % CALL: ao = set(ao, 'name', 'name'); 0009 % ao = set(ao, 'provenance', provenance-object); 0010 % ao = set(ao, 'description','description'); 0011 % ao = set(ao, 'hist', history-object); 0012 % ao = set(ao, 'data', data); 0013 % ao = set(ao, 'mfile', mfile); 0014 % ao = set(ao, 'mfilename', 'mfilename'); 0015 % ao = set(ao, 'mdlfile', 'mdlfile'); 0016 % ao = set(ao, 'mdlfilename','mdlfilename'); 0017 % ao = set(ao, 'version', 'cvs-version'); 0018 % ao = set(ao, 'created', time-object); 0019 % ao = set(ao, plist-object); --> plist-object with key/value paies 0020 % ao = set(ao, 'fs', fs); --> ao.data.fs = fs; 0021 % ao = set(ao, 't0', t0); --> ao.data.t0 = t0; 0022 % ao = set(ao, 'xunits', 'xunits'); --> ao.data.xunits = 'xunits'; 0023 % ao = set(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 = ao(ao, 'Params') 0029 % 0030 % VERSION: $Id: set.m,v 1.22 2007/11/26 14:48:13 ingo Exp $ 0031 % 0032 % HISTORY: 30-01-07 M Hewitson 0033 % Creation 0034 % 0035 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0036 0037 VERSION = '$Id: set.m,v 1.22 2007/11/26 14:48:13 ingo Exp $'; 0038 0039 % Check if this is a call for parameters or for the cvs-version number 0040 if nargin == 2 0041 if isa(ao, 'ao') && ischar(varargin{1}) 0042 in = char(varargin{1}); 0043 if strcmp(in, 'Params') 0044 ao = getDefaultPL(); 0045 return 0046 elseif strcmp(in, 'Version') 0047 ao = VERSION; 0048 return 0049 end 0050 end 0051 end 0052 0053 if (nargout ~= 0) 0054 0055 hist_pl = plist(); 0056 fields = fieldnames(ao); 0057 propArgin = varargin; 0058 0059 if nargin >= 2 && isa(propArgin{1}, 'plist') 0060 pl = propArgin{1}; 0061 propArgin = {}; 0062 for ii = 1:nparams(pl) 0063 %% The 'key' name of a plist/param is alway stored with upper case 0064 %% characters. To set a ao property with this key we have to lower the 0065 %% 'key' characters. 0066 propArgin{end+1} = lower(pl.params(ii).key); 0067 propArgin{end+1} = pl.params(ii).val; 0068 end 0069 end 0070 0071 0072 while length(propArgin) >= 2 0073 prop = propArgin{1}; 0074 val = propArgin{2}; 0075 propArgin = propArgin(3:end); 0076 0077 if ~ismember(prop, [fields; 't0'; 'fs'; 'xunits'; 'yunits']) 0078 error(['### ', prop, ' is not a valid analysis object property.']); 0079 else 0080 0081 %% For all analysis objects (ao can be a vector or a matrix) 0082 for jj = 1:numel(ao) 0083 0084 %% Also pass through some parameters to data object 0085 if strcmp(prop, 'fs') 0086 d = ao(jj).data; 0087 if isa(d, 'tsdata') || isa(d, 'fsdata') 0088 d = set(d, 'fs', val); 0089 else 0090 error('### No ''fs'' property for this data type'); 0091 end 0092 ao(jj).data = d; 0093 0094 elseif strcmp(prop, 't0') 0095 d = ao(jj).data; 0096 if isa(d, 'tsdata') 0097 d = set(d, 't0', val); 0098 else 0099 error('### The data object is not from the class tsdata'); 0100 end 0101 ao(jj).data = d; 0102 0103 elseif strcmp(prop, 'xunits') 0104 d = ao(jj).data; 0105 d = set(d, 'xunits', val); 0106 ao(jj).data = d; 0107 0108 elseif strcmp(prop, 'yunits') 0109 d = ao(jj).data; 0110 d = set(d, 'yunits', val); 0111 ao(jj).data = d; 0112 0113 else 0114 ao(jj).(prop) = val; 0115 end 0116 0117 end % for 0118 0119 end 0120 0121 hist_pl = append(hist_pl, prop, val); 0122 0123 end 0124 0125 for jj = 1:numel(ao) 0126 h = history('set', VERSION, hist_pl); 0127 h = set(h, 'inhists', ao(jj).hist); 0128 h = set(h, 'invars', cellstr(inputname(1))); 0129 0130 ao(jj).hist = h; 0131 end 0132 0133 else 0134 if ischar(varargin{2}) 0135 error('### please use: %s = set(%s, ''%s'', ''%s'');', ... 0136 inputname(1), ... 0137 inputname(1), ... 0138 varargin{1}, ... 0139 varargin{2}); 0140 elseif isnumeric(varargin{2}) 0141 error('### please use: %s = set(%s, ''%s'', %d);', ... 0142 inputname(1), ... 0143 inputname(1), ... 0144 varargin{1}, ... 0145 varargin{2}); 0146 else 0147 error('### please use: %s = set(%s, ''key'', ''value'');', ... 0148 inputname(1), ... 0149 inputname(1)); 0150 end 0151 0152 end 0153 0154 0155 % Get default params 0156 function plo = getDefaultPL() 0157 0158 plo = plist();