Home > classes > @ao > setnh.m

setnh

PURPOSE ^

SET set an analysis object property without recording the history.

SYNOPSIS ^

function ao = setnh(ao, varargin)

DESCRIPTION ^

 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, 'tag',         tag);
       ao = setnh(ao, 'provenance',  provenance-object);
       ao = setnh(ao, 'comment',    'comment');
       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;

 The following call returns a parameter list object that contains the
 default parameter values:

 >> pl = ao(ao, 'Params')

 VERSION: $Id: setnh.m,v 1.1 2007/10/26 14:33:30 hewitson Exp $

 HISTORY: 30-01-07 M Hewitson
             Creation

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

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

Generated on Thu 01-Nov-2007 09:42:34 by m2html © 2003