Home > classes > @ao > fromTSfcn.m

fromTSfcn

PURPOSE ^

FROMTSFCN Construct an ao from a ts-function string

SYNOPSIS ^

function a = fromTSfcn(a, pli)

DESCRIPTION ^

 FROMTSFCN Construct an ao from a ts-function string
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 FUNCTION:    fromTSfcn

 DESCRIPTION: Construct an ao from a ts-function string

 CALL:        a = fromTSfcn(pl)

 PARAMETER:
              pl:       Parameter list object

 HISTORY:     07-05-2007 Hewitson
              Creation

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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % FROMTSFCN Construct an ao from a ts-function string
0002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0003 %
0004 % FUNCTION:    fromTSfcn
0005 %
0006 % DESCRIPTION: Construct an ao from a ts-function string
0007 %
0008 % CALL:        a = fromTSfcn(pl)
0009 %
0010 % PARAMETER:
0011 %              pl:       Parameter list object
0012 %
0013 % HISTORY:     07-05-2007 Hewitson
0014 %              Creation
0015 %
0016 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0017 function a = fromTSfcn(a, pli)
0018 
0019   VERSION = '$Id: fromTSfcn.m,v 1.12 2008/09/04 13:37:14 ingo Exp $';
0020 
0021   % get AO info
0022   ii = ao.getInfo('ao', 'From Time-series Function');
0023 
0024   % Set the method version string in the minfo object
0025   ii.setMversion([VERSION '-->' ii.mversion]);
0026 
0027   % Add default values
0028   pl = combine(pli, ii.plists);
0029 
0030   nsecs       = find(pl, 'nsecs');
0031   fs          = find(pl, 'fs');
0032   fcn         = find(pl, 'tsfcn');
0033   randn_state = find(pl, 'rand_state');
0034   t0          = find(pl, 't0');
0035 
0036   if isempty(t0)
0037     t0 = time(0);
0038   end
0039 
0040   % construct tsdata
0041   t = linspace(0, nsecs-1/fs, nsecs*fs);
0042 
0043   % make y data
0044 
0045   % If the randn state is in the parameter list then set the randn function to
0046   % this sate
0047   if ~isempty(randn_state)
0048     randn('state',randn_state);
0049   else % Store the state of the random function in the parameter list
0050     randn('state',sum(100*clock));
0051     randn_state = randn('state');
0052     % we must make a copy here, other wise all other calls
0053     % using the input plist will get the same random state
0054     pl.append('rand_state', randn_state);
0055   end
0056 
0057   y = eval([fcn ';']);
0058 
0059   ts = tsdata(t,y);
0060   ts.setXunits('s');
0061   ts.setYunits('V');
0062   ts.setT0(t0);
0063 
0064   % Make an analysis object
0065   a.data = ts;
0066   % Add history
0067   a.addHistory(ii, pl, [], []);
0068 
0069 end
0070 
0071

Generated on Mon 08-Sep-2008 13:18:47 by m2html © 2003