Home > classes > @ao > fromFSfcn.m

fromFSfcn

PURPOSE ^

FROMFSFCN Construct an ao from a fs-function string

SYNOPSIS ^

function a = fromFSfcn(a, pli)

DESCRIPTION ^

 FROMFSFCN Construct an ao from a fs-function string
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 FUNCTION:    fromFSfcn

 DESCRIPTION: Construct an ao from a fs-function string

 CALL:        a = fromFSfcn(a, 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 % FROMFSFCN Construct an ao from a fs-function string
0002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0003 %
0004 % FUNCTION:    fromFSfcn
0005 %
0006 % DESCRIPTION: Construct an ao from a fs-function string
0007 %
0008 % CALL:        a = fromFSfcn(a, pl)
0009 %
0010 % PARAMETER:
0011 %              pl:       Parameter list object
0012 %
0013 % HISTORY:     07-05-2007 Hewitson
0014 %              Creation
0015 %
0016 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0017 function a = fromFSfcn(a, pli)
0018 
0019   VERSION = '$Id: fromFSfcn.m,v 1.10 2008/08/22 14:11:33 ingo Exp $';
0020   % get AO info
0021   ii = ao.getInfo('ao', 'From Frequency-series Function');
0022 
0023   % Set the method version string in the minfo object
0024   ii.setMversion([VERSION '-->' ii.mversion]);
0025 
0026   % Add default values
0027   pl          = combine(pli, ao.getDefaultPlist('From Frequency-series Function'));
0028   f           = find(pl, 'f');
0029   randn_state = find(pl, 'rand_state');
0030 
0031   % If the randn state is in the parameter list then set the randn function to
0032   % this sate
0033   if ~isempty(randn_state)
0034     randn('state',randn_state);
0035   else % Store the state of the random function in the parameter list
0036     randn_state = randn('state');
0037     pli.append('rand_state', randn_state);
0038   end
0039 
0040   if isempty(f)
0041     disp('--- generating f')
0042     f1 = find(pl, 'f1');
0043     f2 = find(pl, 'f2');
0044     nf = find(pl, 'nf');
0045     scale = find(pl, 'scale');
0046     switch scale
0047       case 'log'
0048         f = logspace(log10(f1), log10(f2), nf);
0049       case 'lin'
0050         f = linspace(f1, f2, nf);
0051       otherwise
0052         error('### Unknown frequency scale specified');
0053     end
0054   end
0055 
0056   % Get the function
0057   fcn = find(pl, 'fsfcn');
0058 
0059   % make y data
0060   y = eval([fcn ';']);
0061 
0062   fs = fsdata(f,y);
0063   fs.setXunits('Hz');
0064 
0065   % Make an analysis object
0066   a.data  = fs;
0067   % Add history
0068   a.addHistory(ii, pli, [], []);
0069 
0070 end
0071

Generated on Mon 25-Aug-2008 22:39:29 by m2html © 2003