Home > classes > @ao > fromPzmodel.m

fromPzmodel

PURPOSE ^

FROMPZMODEL Construct a time-series ao from polynomial coefficients

SYNOPSIS ^

function a = fromPzmodel(a, pli)

DESCRIPTION ^

 FROMPZMODEL Construct a time-series ao from polynomial coefficients
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 FUNCTION:    fromPzmodel

 DESCRIPTION: Construct a time-series ao from polynomial coefficients

 CALL:        a = fromPzmodel(a, pl)

 PARAMETER:
              pl:       plist containing 'pzmodel', 'Nsecs', 'fs'

 HISTORY:     14-05-2008 Hewitson
              Creation

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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % FROMPZMODEL Construct a time-series ao from polynomial coefficients
0002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0003 %
0004 % FUNCTION:    fromPzmodel
0005 %
0006 % DESCRIPTION: Construct a time-series ao from polynomial coefficients
0007 %
0008 % CALL:        a = fromPzmodel(a, pl)
0009 %
0010 % PARAMETER:
0011 %              pl:       plist containing 'pzmodel', 'Nsecs', 'fs'
0012 %
0013 % HISTORY:     14-05-2008 Hewitson
0014 %              Creation
0015 %
0016 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0017 function a = fromPzmodel(a, pli)
0018 
0019   VERSION = '$Id: fromPzmodel.m,v 1.11 2008/09/07 11:09:50 hewitson Exp $';
0020 
0021   % get AO info
0022   ii = ao.getInfo('ao', 'From Pzmodel');
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   pzm     = find(pl, 'pzmodel');
0031   nsecs   = find(pl, 'Nsecs');
0032   fs      = find(pl, 'fs');
0033   ndigits = find(pl, 'ndigits');
0034 
0035   % Build t vector
0036   if isempty(nsecs) || nsecs == 0
0037     error('### Please provide ''Nsecs'' for pzmodel constructor.');
0038   end
0039   if  isempty(fs) || fs == 0
0040     error('### Please provide ''fs'' for pzmodel constructor.');
0041   end
0042   % t = linspace(0, nsecs - 1/fs, nsecs*fs);
0043 
0044   % Run noise generator
0045   % conversion
0046   disp('  - Filter coefficients are calculated from input pzmodel.');
0047   [num, den] = ao.ngconv(pzm);
0048 
0049   % create matrices
0050   toolboxinfo = ver('symbolic');
0051 
0052   if  isempty(toolboxinfo)
0053     disp('the time series is calculated without the symbolic math toolbox')
0054     disp('  - Matrices are calculated from evaluated denominator coefficients.');
0055     [Tinit, Tprop, E] = ao.ngsetup(den, fs);
0056   else
0057     disp('the time series is calculated using the symbolic math toolbox')
0058     disp('  - Matrices are calculated from evaluated denominator coefficients.');
0059     if isempty(ndigits)
0060       ndigits = 32;
0061       warning('### set number of digits to 32!')
0062     end
0063     [Tinit, Tprop, E] = ao.ngsetup_vpa(den, fs, ndigits);
0064   end
0065 
0066   % set state vector
0067   disp('  - Since there is no given state vector it will be calculated.');
0068 
0069   % make initial state vector
0070   y = ao.nginit(Tinit);
0071 
0072   % propagate to make noise vector
0073   [x, yo] = ao.ngprop(Tprop, E, num, y, fs*nsecs);
0074 
0075   % build variables into data object
0076   t = x*pzm.gain;
0077   a.data = tsdata(t,fs);
0078   a.setName(sprintf('noisegen(%s)', pzm.name), 'internal');
0079 
0080   % Set units to a sensible default
0081   a.setXunits('s', 'internal');
0082   a.setYunits('V', 'internal');
0083 
0084   % Add history
0085   a.addHistory(ii, pl, [], pzm.hist);
0086 
0087 end
0088 
0089

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