comparison m-toolbox/test/new_ltf_code/ltpda_ltf_plan.m @ 0:f0afece42f48

Import.
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 23 Nov 2011 19:22:13 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:f0afece42f48
1 function varargout = ltpda_ltf_plan(varargin)
2
3 % LTPDA_LTF_PLAN computes all input values needed for the LPSD and LTFE
4 % algorithms.
5 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6 %
7 % LTPDA_LTF_PLAN computes all input values needed for the LPSD and LTFE
8 % algorithms.
9 %
10 % Usage:
11 % >> [f, r, b, L, K] = ltpda_ltf_plan(Ndata, fs, olap, bmin, Lmin, Jdes, Kdes)
12 %
13 % Inputs:
14 % Ndata - the length of the time-series to be processed
15 % fs - the sample rate of the time-series to be processed
16 % olap - overlap percentage, usually taken from the window function
17 % bmin - the minimum bin number to be used. This is usually taken
18 % from the window function.
19 % Lmin - The minimum segment length.
20 % Jdes - the desired number of frequencies.
21 % Kdes - The desired number of averages.
22 %
23 % Outputs:
24 % Each output is a vector, one value per frequency:
25 %
26 % f - the frequency
27 % r - frequency resolution (Hz)
28 % b - bin number
29 % L - segment lengths
30 % K - number of averages
31 %
32 % Parameter list:
33 %
34 % The following call returns a parameter list object that contains the
35 % default parameter values:
36 %
37 % >> pl = ltpda_ltf_plan('Params')
38 %
39 % The following call returns a string that contains the routine CVS version:
40 %
41 % >> version = ltpda_ltf_plan('Version')
42 %
43 % The following call returns a string that contains the routine category:
44 %
45 % >> category = ltpda_ltf_plan('Category')
46 %
47 %
48 % REFERENCE: "lpsd revisited: ltf" / S2-AEI-TN-3052
49 % 2008/02/07 V1.1
50 % G Heinzel
51 %
52 %
53 % M Hewitson 19-02-08
54 %
55 % $Id: ltpda_ltf_plan.m,v 1.1 2008/02/19 09:11:32 hewitson Exp $
56 %
57 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
58
59 % q - a vector of start indices for the segments
60
61
62 VERSION = '$Id: ltpda_ltf_plan.m,v 1.1 2008/02/19 09:11:32 hewitson Exp $';
63 CATEGORY = 'Internal';
64
65
66 %% Check if this is a call for parameters, the CVS version string
67 % or the function category
68 if nargin == 1 && ischar(varargin{1})
69 in = char(varargin{1});
70 if strcmp(in, 'Params')
71 varargout{1} = getDefaultPL();
72 return
73 elseif strcmp(in, 'Version')
74 varargout{1} = VERSION;
75 return
76 elseif strcmp(in, 'Category')
77 varargout{1} = CATEGORY;
78 return
79 end
80 end
81
82 %% ------ Check inputs ------------------------------------------------
83 if nargin ~= 7 || nargout ~= 5
84 help(mfilename)
85 error('### Incorrect usage');
86 end
87
88 Ndata = varargin{1};
89 fs = varargin{2};
90 olap = varargin{3};
91 bmin = varargin{4};
92 Lmin = varargin{5};
93 Jdes = varargin{6};
94 Kdes = varargin{7};
95
96 %% ------ Set up some variables -------------------------------------------
97
98 xov = (1 - olap/100);
99 fmin = fs / Ndata * bmin;
100 fmax = fs/2;
101 fresmin = fs / Ndata;
102 freslim = fresmin * (1+xov*(Kdes-1));
103 logfact = (Ndata/2)^(1/Jdes) - 1;
104
105
106
107 %% ------ Prepare outputs -------------------------------------------
108
109 f = [];
110 r = [];
111 b = [];
112 L = [];
113 K = [];
114 % q = [];
115
116 %% ------ Loop over frequency -------------------------------------------
117 fi = fmin;
118 while fi < fmax
119
120 fres = fi * logfact;
121 if fres <= freslim
122 fres = sqrt(fres*freslim);
123 end
124 if fres < fresmin
125 fres = fresmin;
126 end
127
128 bin = fi/fres;
129 if bin < bmin
130 bin = bmin;
131 fres = fi/bin;
132 end
133
134 dftlen = round(fs / fres);
135 if dftlen > Ndata
136 dftlen = Ndata;
137 end
138 if dftlen < Lmin
139 dftlen = Lmin;
140 end
141
142 nseg = round((Ndata - dftlen) / (xov*dftlen) + 1);
143 if nseg == 1
144 dftlen = Ndata;
145 end
146
147 fres = fs / dftlen;
148 bin = fi / fres;
149
150 % Store outputs
151 f = [f fi];
152 r = [r fres];
153 b = [b bin];
154 L = [L dftlen];
155 K = [K nseg];
156
157 fi = fi + fres;
158
159 end
160
161 %% ------ Set outputs -------------------------------------------
162
163 varargout{1} = f;
164 varargout{2} = r;
165 varargout{3} = b;
166 varargout{4} = L;
167 varargout{5} = K;
168
169
170 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
171 %
172 % FUNCTION: getDefaultPL
173 %
174 % DESCRIPTION: Get default params
175 %
176 % HISTORY: 19-02-08 M Hewitson
177 % Creation
178 %
179 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
180 function plo = getDefaultPL()
181
182 plo = plist('Ndata', 10, ...
183 'fs', 10, ...
184 'olap', 50, ...
185 'bmin', 1, ...
186 'Lmin', 1e20, ...
187 'Jdes', 1000, ...
188 'Kdes', 100 ...
189 );
190
191
192 % END