Mercurial > hg > ltpda
comparison m-toolbox/classes/@ao/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 % LTF_PLAN computes all input values needed for the LPSD and LTFE algorithms. | |
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
3 % | |
4 % DESCRIPTION: LTF_PLAN computes all input values needed for the LPSD and LTFE | |
5 % algorithms. | |
6 % | |
7 % CALL: [f, r, b, L, K] = ltf_plan(Ndata, fs, olap, bmin, Lmin, Jdes, Kdes) | |
8 % | |
9 % INPUTS: Ndata - the length of the time-series to be processed | |
10 % fs - the sample rate of the time-series to be processed | |
11 % olap - overlap percentage, usually taken from the window function | |
12 % bmin - the minimum bin number to be used. This is usually taken | |
13 % from the window function. | |
14 % Lmin - The minimum segment length. | |
15 % Jdes - the desired number of frequencies. | |
16 % Kdes - The desired number of averages. | |
17 % | |
18 % OUTPUTS: Each output is a vector, one value per frequency: | |
19 % f - the frequency | |
20 % r - frequency resolution (Hz) | |
21 % b - bin number | |
22 % L - segment lengths | |
23 % K - number of averages | |
24 % | |
25 % PARAMETER LIST: | |
26 % | |
27 % VERSION: $Id: ltf_plan.m,v 1.6 2009/08/31 17:09:43 ingo Exp $ | |
28 % | |
29 % HISTORY: 19-02-2008 M Hewitson | |
30 % Creation | |
31 % | |
32 % REFERENCE: "lpsd revisited: ltf" / S2-AEI-TN-3052 | |
33 % 2008/02/07 V1.1 | |
34 % G Heinzel | |
35 % | |
36 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
37 | |
38 % q - a vector of start indices for the segments | |
39 | |
40 function varargout = ltf_plan(varargin) | |
41 | |
42 %% ------ Check inputs ------------------------------------------------ | |
43 if nargin ~= 7 || nargout ~= 5 | |
44 help(mfilename) | |
45 error('### Incorrect usage'); | |
46 end | |
47 | |
48 Ndata = varargin{1}; | |
49 fs = varargin{2}; | |
50 olap = varargin{3}; | |
51 bmin = varargin{4}; | |
52 Lmin = varargin{5}; | |
53 Jdes = varargin{6}; | |
54 Kdes = varargin{7}; | |
55 | |
56 %% ------ Set up some variables ------------------------------------------- | |
57 | |
58 xov = (1 - olap/100); | |
59 fmin = fs / Ndata * bmin; | |
60 fmax = fs/2; | |
61 fresmin = fs / Ndata; | |
62 freslim = fresmin * (1+xov*(Kdes-1)); | |
63 logfact = (Ndata/2)^(1/Jdes) - 1; | |
64 | |
65 | |
66 | |
67 %% ------ Prepare outputs ------------------------------------------- | |
68 | |
69 f = []; | |
70 r = []; | |
71 b = []; | |
72 L = []; | |
73 K = []; | |
74 % q = []; | |
75 | |
76 %% ------ Loop over frequency ------------------------------------------- | |
77 fi = fmin; | |
78 while fi < fmax | |
79 | |
80 fres = fi * logfact; | |
81 if fres <= freslim | |
82 fres = sqrt(fres*freslim); | |
83 end | |
84 if fres < fresmin | |
85 fres = fresmin; | |
86 end | |
87 | |
88 bin = fi/fres; | |
89 if bin < bmin | |
90 bin = bmin; | |
91 fres = fi/bin; | |
92 end | |
93 | |
94 dftlen = round(fs / fres); | |
95 if dftlen > Ndata | |
96 dftlen = Ndata; | |
97 end | |
98 if dftlen < Lmin | |
99 dftlen = Lmin; | |
100 end | |
101 | |
102 nseg = round((Ndata - dftlen) / (xov*dftlen) + 1); | |
103 if nseg == 1 | |
104 dftlen = Ndata; | |
105 end | |
106 | |
107 fres = fs / dftlen; | |
108 bin = fi / fres; | |
109 | |
110 % Store outputs | |
111 f = [f fi]; | |
112 r = [r fres]; | |
113 b = [b bin]; | |
114 L = [L dftlen]; | |
115 K = [K nseg]; | |
116 | |
117 fi = fi + fres; | |
118 | |
119 end | |
120 | |
121 %% ------ Set outputs ------------------------------------------- | |
122 | |
123 varargout{1} = f.'; | |
124 varargout{2} = r.'; | |
125 varargout{3} = b.'; | |
126 varargout{4} = L.'; | |
127 varargout{5} = K.'; | |
128 end | |
129 |