LTPDA_LTF_PLAN computes all input values needed for the LPSD and LTFE algorithms. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LTPDA_LTF_PLAN computes all input values needed for the LPSD and LTFE algorithms. Usage: >> [f, r, b, L, K] = ltpda_ltf_plan(Ndata, fs, olap, bmin, Lmin, Jdes, Kdes) Inputs: Ndata - the length of the time-series to be processed fs - the sample rate of the time-series to be processed olap - overlap percentage, usually taken from the window function bmin - the minimum bin number to be used. This is usually taken from the window function. Lmin - The minimum segment length. Jdes - the desired number of frequencies. Kdes - The desired number of averages. Outputs: Each output is a vector, one value per frequency: f - the frequency r - frequency resolution (Hz) b - bin number L - segment lengths K - number of averages Parameter list: The following call returns a parameter list object that contains the default parameter values: >> pl = ltpda_ltf_plan('Params') The following call returns a string that contains the routine CVS version: >> version = ltpda_ltf_plan('Version') The following call returns a string that contains the routine category: >> category = ltpda_ltf_plan('Category') REFERENCE: "lpsd revisited: ltf" / S2-AEI-TN-3052 2008/02/07 V1.1 G Heinzel M Hewitson 19-02-08 $Id: ltpda_ltf_plan.html,v 1.4 2008/03/31 10:27:39 hewitson Exp $ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0001 function varargout = ltpda_ltf_plan(varargin) 0002 0003 % LTPDA_LTF_PLAN computes all input values needed for the LPSD and LTFE 0004 % algorithms. 0005 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0006 % 0007 % LTPDA_LTF_PLAN computes all input values needed for the LPSD and LTFE 0008 % algorithms. 0009 % 0010 % Usage: 0011 % >> [f, r, b, L, K] = ltpda_ltf_plan(Ndata, fs, olap, bmin, Lmin, Jdes, Kdes) 0012 % 0013 % Inputs: 0014 % Ndata - the length of the time-series to be processed 0015 % fs - the sample rate of the time-series to be processed 0016 % olap - overlap percentage, usually taken from the window function 0017 % bmin - the minimum bin number to be used. This is usually taken 0018 % from the window function. 0019 % Lmin - The minimum segment length. 0020 % Jdes - the desired number of frequencies. 0021 % Kdes - The desired number of averages. 0022 % 0023 % Outputs: 0024 % Each output is a vector, one value per frequency: 0025 % 0026 % f - the frequency 0027 % r - frequency resolution (Hz) 0028 % b - bin number 0029 % L - segment lengths 0030 % K - number of averages 0031 % 0032 % Parameter list: 0033 % 0034 % The following call returns a parameter list object that contains the 0035 % default parameter values: 0036 % 0037 % >> pl = ltpda_ltf_plan('Params') 0038 % 0039 % The following call returns a string that contains the routine CVS version: 0040 % 0041 % >> version = ltpda_ltf_plan('Version') 0042 % 0043 % The following call returns a string that contains the routine category: 0044 % 0045 % >> category = ltpda_ltf_plan('Category') 0046 % 0047 % 0048 % REFERENCE: "lpsd revisited: ltf" / S2-AEI-TN-3052 0049 % 2008/02/07 V1.1 0050 % G Heinzel 0051 % 0052 % 0053 % M Hewitson 19-02-08 0054 % 0055 % $Id: ltpda_ltf_plan.html,v 1.4 2008/03/31 10:27:39 hewitson Exp $ 0056 % 0057 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0058 0059 % q - a vector of start indices for the segments 0060 0061 0062 VERSION = '$Id: ltpda_ltf_plan.html,v 1.4 2008/03/31 10:27:39 hewitson Exp $'; 0063 CATEGORY = 'Internal'; 0064 0065 0066 %% Check if this is a call for parameters, the CVS version string 0067 % or the function category 0068 if nargin == 1 && ischar(varargin{1}) 0069 in = char(varargin{1}); 0070 if strcmp(in, 'Params') 0071 varargout{1} = getDefaultPL(); 0072 return 0073 elseif strcmp(in, 'Version') 0074 varargout{1} = VERSION; 0075 return 0076 elseif strcmp(in, 'Category') 0077 varargout{1} = CATEGORY; 0078 return 0079 end 0080 end 0081 0082 %% ------ Check inputs ------------------------------------------------ 0083 if nargin ~= 7 || nargout ~= 5 0084 help(mfilename) 0085 error('### Incorrect usage'); 0086 end 0087 0088 Ndata = varargin{1}; 0089 fs = varargin{2}; 0090 olap = varargin{3}; 0091 bmin = varargin{4}; 0092 Lmin = varargin{5}; 0093 Jdes = varargin{6}; 0094 Kdes = varargin{7}; 0095 0096 %% ------ Set up some variables ------------------------------------------- 0097 0098 xov = (1 - olap/100); 0099 fmin = fs / Ndata * bmin; 0100 fmax = fs/2; 0101 fresmin = fs / Ndata; 0102 freslim = fresmin * (1+xov*(Kdes-1)); 0103 logfact = (Ndata/2)^(1/Jdes) - 1; 0104 0105 0106 0107 %% ------ Prepare outputs ------------------------------------------- 0108 0109 f = []; 0110 r = []; 0111 b = []; 0112 L = []; 0113 K = []; 0114 % q = []; 0115 0116 %% ------ Loop over frequency ------------------------------------------- 0117 fi = fmin; 0118 while fi < fmax 0119 0120 fres = fi * logfact; 0121 if fres <= freslim 0122 fres = sqrt(fres*freslim); 0123 end 0124 if fres < fresmin 0125 fres = fresmin; 0126 end 0127 0128 bin = fi/fres; 0129 if bin < bmin 0130 bin = bmin; 0131 fres = fi/bin; 0132 end 0133 0134 dftlen = round(fs / fres); 0135 if dftlen > Ndata 0136 dftlen = Ndata; 0137 end 0138 if dftlen < Lmin 0139 dftlen = Lmin; 0140 end 0141 0142 nseg = round((Ndata - dftlen) / (xov*dftlen) + 1); 0143 if nseg == 1 0144 dftlen = Ndata; 0145 end 0146 0147 fres = fs / dftlen; 0148 bin = fi / fres; 0149 0150 % Store outputs 0151 f = [f fi]; 0152 r = [r fres]; 0153 b = [b bin]; 0154 L = [L dftlen]; 0155 K = [K nseg]; 0156 0157 fi = fi + fres; 0158 0159 end 0160 0161 %% ------ Set outputs ------------------------------------------- 0162 0163 varargout{1} = f; 0164 varargout{2} = r; 0165 varargout{3} = b; 0166 varargout{4} = L; 0167 varargout{5} = K; 0168 0169 0170 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0171 % 0172 % FUNCTION: getDefaultPL 0173 % 0174 % DESCRIPTION: Get default params 0175 % 0176 % HISTORY: 19-02-08 M Hewitson 0177 % Creation 0178 % 0179 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0180 function plo = getDefaultPL() 0181 0182 plo = plist('Ndata', 10, ... 0183 'fs', 10, ... 0184 'olap', 50, ... 0185 'bmin', 1, ... 0186 'Lmin', 1e20, ... 0187 'Jdes', 1000, ... 0188 'Kdes', 100 ... 0189 ); 0190 0191 0192 % END