comparison m-toolbox/html_help/help/ug/specwin_using_content.html @ 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 <p>
2 Spectral windows are typically used in spectral analysis algorithms. In all LTPDA spectral analysis
3 functions, spectral windows are specified as parameters in an input parameter list. The following
4 example shows the use of <tt>ao/psd</tt> to estimate an Amplitude Spectral Density of
5 the time-series captured in the input AO, <tt>a</tt>. The help for <a href="matlab:doc('ao/ao/psd')">ao/lpsd</a>
6 reveals that the required parameter for setting the window function is <tt>'Win'</tt>.
7 </p>
8 <div class="fragment"><pre>
9 <br> <span class="comment">% Parameters</span>
10 nsecs = 1000;
11 fs = 10;
12
13 <span class="comment">% Create input AOs</span>
14 x1 = ao(plist( <span class="string">'waveform'</span>, <span class="string">'sine wave'</span>, <span class="string">'f'</span>,0.1, <span class="string">'A'</span>,1, <span class="string">'nsecs'</span>,nsecs, <span class="string">'fs'</span>,fs));
15 x2 = ao(plist( <span class="string">'waveform'</span>, <span class="string">'noise'</span>, <span class="string">'type'</span>, <span class="string">'normal'</span>, <span class="string">'nsecs'</span>,nsecs, <span class="string">'fs'</span>,fs));
16
17 <span class="comment">% Add both</span>
18 x = x1 + x2;
19
20 <span class="comment">% Compute psd with Blackman-Harris window</span>
21 z = psd(x,plist(<span class="string">'win'</span>,<span class="string">'BH92'</span>));
22
23 <span class="comment">% Plot</span>
24 iplot(z);
25 </pre></div>
26 <p>
27 In this case, the size of the spectral window (number of samples) may not match the length
28 of the segments in the spectral estimation. The <tt>psd</tt> algorithm then
29 recomputes the window using the input design but for the correct length of window function.
30 </p>
31
32 <img src="images/specwin_using1.png" >
33
34 <h2>Selecting the Peak Side-Lobe level (psll) with Kaiser's window</h2>
35 <p>
36 The <a href="specwin_description.html">table</a> in the previous section shows how each standard spectral window is defined by the
37 Peak Side-Lobe level (<tt>psll</tt>). However, Kaiser's window allows the user to define the <tt>psll</tt> of the window.
38 </p>
39 <p>
40 The following example shows the importance of selecting a suitable <tt>psll</tt> according to each application. The example creates
41 1/f noise (in fact, noise generated
42 by a pole-zero model with a pole at low frequencies) and computes the Amplitude Spectrum Density (ASD) with three different <tt>psll</tt>
43 values. The ASD with the lowest value shows a bias at high frequencies compared with the response of the pzmodel used to generate
44 the data (in black). This effect is due to the power added by the high order lobes of the window. The ASD with the highet value of the
45 <tt>psll</tt> adds a feature at low frequencies because the main lobe of the window is too wide. Only the
46 middle value gives an estimation of the ASD without adding window related features.
47 </p>
48
49 <div class="fragment"><pre>
50 <br> <span class="comment">% Parameters</span>
51 nsecs = 10000;
52 fs = 1;
53
54 <span class="comment">% Create pzmodel with a low frequency pole</span>
55 pzm = pzmodel(1e5,[1e-7,0.1],[]);
56
57 <span class="comment">% Build (nearly) 1/f noise</span>
58 x = ao(plist(<span class="string">'pzmodel'</span>,pzm, <span class="string">'nsecs'</span>,nsecs, <span class="string">'fs'</span>,fs));
59
60 <span class="comment">% Compute psd with Blackman-Harris window</span>
61 z1 = psd(x,plist(<span class="string">'scale'</span>,<span class="string">'ASD'</span>,<span class="string">'win'</span>,<span class="string">'Kaiser'</span>,<span class="string">'psll'</span>,50));
62 z1.setName(<span class="string">'psll = 50'</span>);
63 z2 = psd(x,plist('scale',<span class="string">'ASD'</span>,<span class="string">'win'</span>,<span class="string">'Kaiser'</span>,<span class="string">'psll'</span>,100));
64 z2.setName(<span class="string">'psll = 100'</span>);
65 z3 = psd(x,plist(<span class="string">'scale'</span>,<span class="string">'ASD'</span>,<span class="string">'win'</span>,<span class="string">'Kaiser'</span>,<span class="string">'psll'</span>,1000));
66 z3.setName(<span class="string">'psll = 1000'</span>);
67
68 <span class="comment">% Plot</span>
69 r = resp(pzm,plist(<span class="string">'f1'</span>,1e-4,<span class="string">'f2'</span>,1));
70 r.setName(<span class="string">'response'</span>)
71 r.setPlotinfo(plist(<span class="string">'color'</span>,<span class="string">'k'</span>))
72 iplot(z1,z2,z3,abs(r));
73 </pre></div>
74
75 <img src="images/specwin_using2.png" >
76
77
78