0
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1 <h2>Description</h2>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
2 <p>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
3 Resampling is the process of changing the sampling rate of data. <a href="matlab:doc('ao/resample')"><tt>Resample</tt></a>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
4 changes the sampling rate of the input AOs to the desired output sampling frequency. LTPDA <a href="matlab:doc('ao/resample')"><tt>resample</tt></a> overloads <tt>resample</tt> function of Matlab Signal Processing Toolbox for AOs.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
5 </p>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
6 <h2>Syntax</h2>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
7 <div class="fragment"><pre>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
8 <br>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
9 b = resample(a, pl)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
10 </pre>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
11 </div>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
12 <h2>Parameters</h2>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
13 <p> The following parameters can be set:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
14 <ul>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
15 <li> <tt>fsout</tt> - specify the desired output frequency (must be positive and integer)</li>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
16 <li> <tt>filter</tt> - specified filter applied to the input, <tt>a</tt>, in the resampling process</li>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
17 </ul>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
18 </p>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
19 <p>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
20 <h2>Examples</h2>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
21 </p>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
22 <p>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
23 2. Resampling a sequence of random data at original sampling rate of 1 Hz at an output sampling of 50 Hz.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
24 </p>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
25 <div class="fragment"><pre>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
26 <br>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
27 <span class="comment">% create an AO of random data with fs = 10 Hz</span>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
28 pl = plist(<span class="string">'tsfcn'</span>, <span class="string">'randn(size(t))'</span>,<span class="string">'fs'</span>,1,<span class="string">'nsecs'</span>,10,<span class="string">'yunits'</span>,<span class="string">'m'</span>,<span class="string">'nsecs'</span>,100);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
29 x = ao(pl);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
30 y = resample(x, plist(<span class="string">'fsout'</span>, 50)); <span class="comment">% resample the input AO (x) to obtain the resampled output AO (y)</span>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
31 iplot(x, y) <span class="comment">% plot original and resampled data</span>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
32 </pre>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
33 </div>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
34 <br>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
35 <br>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
36 <img src="images/resample1.png" alt="Resample">
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
37 <br>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
38 <br>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
39 <br>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
40 <p>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
41 1. Resampling a sequence of random data at original sampling rate of 10 Hz at an output sampling of 1 Hz with
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
42 a filter defined by the user.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
43 </p>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
44 <div class="fragment"><pre>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
45 <br>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
46 <span class="comment">% create an AO of random data with fs = 10 Hz</span>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
47 pl = plist(<span class="string">'tsfcn'</span>, <span class="string">'randn(size(t))'</span>,<span class="string">'fs'</span>,10,<span class="string">'nsecs'</span>,10,<span class="string">'yunits'</span>,<span class="string">'m'</span>);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
48 x = ao(pl)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
49
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
50 <span class="comment">% filter definition</span>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
51 plfilter = plist(<span class="string">'type'</span>,<span class="string">'lowpass'</span>,<span class="string">'Win'</span>,specwin(<span class="string">'Kaiser'</span>, 10, 150),<span class="string">'order'</span>,32,<span class="string">'fs'</span>,10,<span class="string">'fc'</span>,1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
52 f = mfir(plfilter)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
53
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
54 <span class="comment">% resampling</span>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
55 pl = plist(<span class="string">'fsout'</span>, 1, <span class="string">'filter'</span>,f); <span class="comment">% define parameters list with fsout = 1 Hz and the defined filter</span>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
56 y = resample(x, pl); <span class="comment">% resample the input AO (x) to obtain the resampled output AO (y)</span>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
57 iplot(x, y) <span class="comment">% plot original and resampled data</span>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
58 </pre>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
59 </div>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
60 <br>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
61 <br>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
62 <img src="images/resample2.png" alt="Resample" border="0">
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
63
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
64
|