FNGEN creates an arbitrarily long time-series based on the input pzmodel. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DESCRIPTION: FNGEN creates an arbitrarily long time-series based on the input pzmodel. CALL: b = fngen(pzm, pl) PARAMETERS: 'Nsecs' - The number of seconds to produce [default: inverse of PSD length] 'Win' - The spectral window to use for blending segments [default: Kaiser -150dB] M-FILE INFO: Get information about this methods by calling >> pzmodel.getInfo('fngen') Get information about a specified set-plist by calling: >> pzmodel.getInfo('fngen', 'none') VERSION: $Id: fngen.m,v 1.10 2008/09/05 14:17:33 hewitson Exp $ HISTORY: 12-03-07 M Hewitson Creation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0001 % FNGEN creates an arbitrarily long time-series based on the input pzmodel. 0002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0003 % 0004 % DESCRIPTION: FNGEN creates an arbitrarily long time-series based on the 0005 % input pzmodel. 0006 % 0007 % CALL: b = fngen(pzm, pl) 0008 % 0009 % PARAMETERS: 'Nsecs' - The number of seconds to produce 0010 % [default: inverse of PSD length] 0011 % 'Win' - The spectral window to use for blending segments 0012 % [default: Kaiser -150dB] 0013 % 0014 % M-FILE INFO: Get information about this methods by calling 0015 % >> pzmodel.getInfo('fngen') 0016 % 0017 % Get information about a specified set-plist by calling: 0018 % >> pzmodel.getInfo('fngen', 'none') 0019 % 0020 % VERSION: $Id: fngen.m,v 1.10 2008/09/05 14:17:33 hewitson Exp $ 0021 % 0022 % HISTORY: 12-03-07 M Hewitson 0023 % Creation 0024 % 0025 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0026 0027 function varargout = fngen(varargin) 0028 0029 %%% Check if this is a call for parameters 0030 if utils.helper.isinfocall(varargin{:}) 0031 varargout{1} = getInfo(varargin{3}); 0032 return 0033 end 0034 0035 % Collect input variable names 0036 in_names = cell(size(varargin)); 0037 for ii = 1:nargin,in_names{ii} = inputname(ii);end 0038 0039 % Collect all AOs and plists 0040 [pzms, pzm_invars] = utils.helper.collect_objects(varargin(:), 'pzmodel', in_names); 0041 pl = utils.helper.collect_objects(varargin(:), 'plist', in_names); 0042 0043 % combine plists 0044 pl = combine(pl, getDefaultPlist()); 0045 0046 % Loop over input pzms 0047 bs(1:numel(pzms)) = ao(); 0048 for j=1:numel(pzms) 0049 % get sample rate to specify Nyquist 0050 fs = find(pl, 'fs'); 0051 if isempty(fs) 0052 fs = round(getupperFreq(pzms(j)) * 10); 0053 end 0054 if fs < 1 0055 fs = 1; 0056 end 0057 0058 % Compute the frequency vector 0059 Nf = 10001; 0060 f1 = 0; 0061 f2 = fs/2; 0062 f = linspace(f1,f2,Nf); 0063 N = 2*(Nf-1); 0064 % Compute model response 0065 w = ao(plist('tsfcn', 'sqrt(fs/2).*randn(size(t))', 'fs', fs, 'Nsecs', N)); 0066 wxx = pwelch(w, plist('Nfft', N, 'win', specwin('Rectangular', N))); 0067 axx = resp(pzms(j), plist('f', f)); 0068 0069 % Compute desired PSD 0070 wxx.setY(wxx.data.y .* (abs(axx.data.y).^2)); 0071 0072 % Call ao/fngen 0073 b = fngen(wxx, pl); 0074 b.setXunits('s'); 0075 b.setYunits(''); 0076 0077 % Add history 0078 b.addHistory(getInfo, pl, pzm_invars(j), pzms(j).hist); 0079 0080 % Add to outputs 0081 bs(j) = b; 0082 end 0083 0084 % Set outputs 0085 varargout{1} = bs; 0086 end 0087 0088 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0089 % Local Functions % 0090 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0091 0092 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0093 % 0094 % FUNCTION: getInfo 0095 % 0096 % DESCRIPTION: Get Info Object 0097 % 0098 % HISTORY: 11-07-07 M Hewitson 0099 % Creation. 0100 % 0101 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0102 0103 function ii = getInfo(varargin) 0104 if nargin == 1 && strcmpi(varargin{1}, 'None') 0105 sets = {}; 0106 pl = []; 0107 else 0108 sets = {'Default'}; 0109 pl = getDefaultPlist; 0110 end 0111 % Build info object 0112 ii = minfo(mfilename, 'pzmodel', '', utils.const.categories.sigproc, '$Id: fngen.m,v 1.10 2008/09/05 14:17:33 hewitson Exp $', sets, pl); 0113 end 0114 0115 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0116 % 0117 % FUNCTION: getDefaultPlist 0118 % 0119 % DESCRIPTION: Get Default Plist 0120 % 0121 % HISTORY: 11-07-07 M Hewitson 0122 % Creation. 0123 % 0124 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0125 0126 function plo = getDefaultPlist() 0127 plo = plist('Nsecs', -1, 'Win', getappdata(0, 'ltpda_default_spectral_window')); 0128 end 0129