Mercurial > hg > ltpda
comparison m-toolbox/html_help/help/ug/ltpda_training_topic_2_4.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 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" | |
2 "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd"> | |
3 | |
4 <html lang="en"> | |
5 <head> | |
6 <meta name="generator" content= | |
7 "HTML Tidy for Mac OS X (vers 1st December 2004), see www.w3.org"> | |
8 <meta http-equiv="Content-Type" content= | |
9 "text/html; charset=us-ascii"> | |
10 | |
11 <title>Interpolation of a time-series AO (LTPDA Toolbox)</title> | |
12 <link rel="stylesheet" href="docstyle.css" type="text/css"> | |
13 <meta name="generator" content="DocBook XSL Stylesheets V1.52.2"> | |
14 <meta name="description" content= | |
15 "Presents an overview of the features, system requirements, and starting the toolbox."> | |
16 </head> | |
17 | |
18 <body> | |
19 <a name="top_of_page" id="top_of_page"></a> | |
20 | |
21 <p style="font-size:1px;"> </p> | |
22 | |
23 <table class="nav" summary="Navigation aid" border="0" width= | |
24 "100%" cellpadding="0" cellspacing="0"> | |
25 <tr> | |
26 <td valign="baseline"><b>LTPDA Toolbox</b></td><td><a href="../helptoc.html">contents</a></td> | |
27 | |
28 <td valign="baseline" align="right"><a href= | |
29 "ltpda_training_topic_2_3.html"><img src="b_prev.gif" border="0" align= | |
30 "bottom" alt="Resampling a time-series AO"></a> <a href= | |
31 "ltpda_training_topic_2_5.html"><img src="b_next.gif" border="0" align= | |
32 "bottom" alt="Remove trends from a time-series AO"></a></td> | |
33 </tr> | |
34 </table> | |
35 | |
36 <h1 class="title"><a name="f3-12899" id="f3-12899"></a>Interpolation of a time-series AO</h1> | |
37 <hr> | |
38 | |
39 <p> | |
40 <p> | |
41 The <tt>ao</tt> class has a method for interpolating data using different forms of interpolation. This method is | |
42 called <tt>ao/interp</tt>. | |
43 </p> | |
44 <p> | |
45 To configure <tt>ao/interp</tt>, use the following parameters: | |
46 <table cellspacing="0" class="body" cellpadding="2" border="0" width="80%"> | |
47 <colgroup> | |
48 <col width="25%"/> | |
49 <col width="75%"/> | |
50 </colgroup> | |
51 <thead> | |
52 <tr valign="top"> | |
53 <th class="categorylist">Key</th> | |
54 <th class="categorylist">Description</th> | |
55 </tr> | |
56 </thead> | |
57 <tbody> | |
58 <!-- Key 'Vertices' --> | |
59 <tr valign="top"> | |
60 <td bgcolor="#f3f4f5"> | |
61 <p><tt>VERTICES</tt></p> | |
62 </td> | |
63 <td bgcolor="#f3f4f5"> | |
64 <p>A new set of vertices (relative to the t0) on which to resample.</p> | |
65 </td> | |
66 </tr> | |
67 <!-- Key 'method' --> | |
68 <tr valign="top"> | |
69 <td bgcolor="#f3f4f5"> | |
70 <p><tt>METHOD</tt></p> | |
71 </td> | |
72 <td bgcolor="#f3f4f5"> | |
73 <p>The method by which to interpolate. Choose from | |
74 <ul> | |
75 <li>'nearest' - nearest neighbour</li> | |
76 <li>'linear' - linear interpolation</li> | |
77 <li>'spline' - for spline interpolation</li> | |
78 <li>'cubic' - for cubic interpolation</li> | |
79 </ul></p> | |
80 </td> | |
81 </tr> | |
82 </tbody> | |
83 </table> | |
84 </p> | |
85 <h2>Example</h2> | |
86 <p> | |
87 Here we will interpolate a sinusoid singal on to a new time-grid. The result will be to increase the | |
88 sample rate by a factor 2. | |
89 </p> | |
90 <p> | |
91 First we create a time-series ao: | |
92 </p> | |
93 <div class="fragment"><pre> | |
94 pl = plist(<span class="string">'Name'</span>, <span class="string">'None'</span>, <span class="string">'tsfcn'</span>,<span class="string">'sin(2*pi*1.733*t)'</span>,<span class="string">'fs'</span>,20,<span class="string">'nsecs'</span>,10,<span class="string">'yunits'</span>,<span class="string">'V'</span>); | |
95 x = ao(pl); | |
96 </pre> | |
97 </div> | |
98 <p> | |
99 Then we create the new time-grid we want to resample on to. | |
100 </p> | |
101 <div class="fragment"><pre> | |
102 tt = linspace(0, x.nsecs - 1/x.fs, 2*(x.len)); | |
103 </pre> | |
104 </div> | |
105 <p> | |
106 And finally we can apply our new time-grid to the data using <tt>interp</tt>. We test two of the available interpolation methods: | |
107 </p> | |
108 <div class="fragment"><pre> | |
109 pl_spline = plist(<span class="string">'vertices'</span>,tt); | |
110 pl_nearest = plist(<span class="string">'vertices'</span>,tt,<span class="string">'method'</span>,<span class="string">'nearest'</span>); | |
111 x_spline = interp(x,pl_spline); | |
112 x_nearest = interp(x,pl_nearest); | |
113 iplot(x, x_spline, x_nearest, plist(<span class="string">'Markers'</span>, {<span class="string">'o'</span>, <span class="string">'+'</span>, <span class="string">'x'</span>}, ... | |
114 <span class="string">'LineColors'</span>, {<span class="string">'k'</span>, <span class="string">'r'</span>, <span class="string">'g'</span>}, ... | |
115 <span class="string">'XRanges'</span>, [0 1])); | |
116 </pre> | |
117 </div> | |
118 <img src="images/ltpda_training_1/topic2/interp.png" alt="Interpolate" border="3"> | |
119 <br> | |
120 <br> | |
121 <p> | |
122 To do the same activity on the workbench, we can use a pipeline like: | |
123 </p> | |
124 <img src="images/ltpda_training_1/topic2/lwb_interp_1.png" alt="Interpolate" border="3"> | |
125 <p> | |
126 This teaches some important aspects of the use of the workbench, so it's worth stepping through its construction slowly. | |
127 </p> | |
128 <p> | |
129 To build this pipeline: | |
130 <ol> | |
131 <li>Create a new empty canvas</li> | |
132 <li>Add two MATLAB Expression Blocks: | |
133 <ol> | |
134 <li>Right-click on the canvas and choose "Add Block...->MATBlock". A <tt>MATBlock</tt> is a block which can | |
135 evaluate any valid MATLAB expression and pass that to further blocks via its single output.</li> | |
136 <li>Select the block, then change its name in the block | |
137 property table (located at the top left of the "Properties" tab) to 'fs'. Alternatively, the name of the block can be changed by right-clicking on the block and choosing "Set name"</li> | |
138 <li>Double-click the block to get a pop-up dialog where you can enter the MATLAB expression. In this case | |
139 just enter the value 20.</li> | |
140 <li>Select this 'fs' block and hit <tt>ctrl-d</tt> (<tt>cmd-d</tt> on OS X) to duplicate the block.</li> | |
141 <li>Select the new block and change its name to 'nsecs'</li> | |
142 <li>Double-click the 'nsecs' block to change its expression. Enter the value 10.</li> | |
143 </ol> | |
144 </li> | |
145 <li>Next we need some additional blocks. Add an <tt>ao</tt> block, two <tt>ao/interp</tt> blocks, an | |
146 <tt>ao/x</tt> block, and an <tt>ao/iplot</tt> block. | |
147 </li> | |
148 <li>Connect up the blocks as shown on the pipeline above. | |
149 <table cellspacing="0" class="note" summary="Note" cellpadding="5" border="1"> | |
150 <tr width="90%"> | |
151 <td> | |
152 To add inputs (or outputs) to a block, right-click on the block and choose "Add input". | |
153 </td> | |
154 </tr> | |
155 </table> | |
156 <table cellspacing="0" class="note" summary="Note" cellpadding="5" border="1"> | |
157 <tr width="90%"> | |
158 <td> | |
159 Double-click an LTPDA Block to get a dialog box to enter a new name for the block. | |
160 </td> | |
161 </tr> | |
162 </table> | |
163 <table cellspacing="0" class="note" summary="Note" cellpadding="5" border="1"> | |
164 <tr width="90%"> | |
165 <td> | |
166 To set the color of the pipes eminating from a particular block, right-click on the block | |
167 and choose "Set output pipe color" from the context menu. You can also set the color of | |
168 individual pipes by right-clicking on a pipe and choosing "Set color" from the context menu. | |
169 </td> | |
170 </tr> | |
171 </table> | |
172 </li> | |
173 <li>Next we need to set the various properties of each block. Follow these steps: | |
174 <ol> | |
175 <li>Set the properties of the AO block to look like:<br> | |
176 <img src="images/ltpda_training_1/topic2/lwb_interp_ao_props.png" alt="Interpolate" border="3"> | |
177 <table cellspacing="0" class="note" summary="Note" cellpadding="5" border="1"> | |
178 <tr width="90%"> | |
179 <td> | |
180 The single quotes around the <tt>TSFCN</tt> value are not strictly necessary, but it can | |
181 avoid problems, for example in the case you have a variable <tt>t</tt> already defined in the MATLAB | |
182 workspace. | |
183 </td> | |
184 </tr> | |
185 </table> | |
186 </li> | |
187 <li> | |
188 Set the properties of the first interpolate block (a_spline) to look like:<br> | |
189 <img src="images/ltpda_training_1/topic2/lwb_interp_ao_interp1.png" alt="Interpolate" border="3"> <br> | |
190 Notice that here we have used the keywords <tt>PORT_1</tt> and <tt>PORT_2</tt> to build the expression. These | |
191 refer to the ports of that block, and are connected to the MATLAB Expression Blocks which represent the values | |
192 we are interested in. | |
193 </li> | |
194 <li> | |
195 The block <tt>ao/x</tt> has no properties and simply gets the full x-vector from the output of <tt>a_spline</tt>. This | |
196 is then passed to the next interpolation block where we use the values as the vertices for the next | |
197 interpolation step, thus ensuring that the two interpolations are done on the same grid. | |
198 </li> | |
199 <li> | |
200 Set the properties of the second interpolate block (a_near) to look like:<br> | |
201 <img src="images/ltpda_training_1/topic2/lwb_interp_ao_interp2.png" alt="Interpolate" border="3"> <br> | |
202 </li> | |
203 <li> | |
204 Finally, for the <tt>iplot</tt> block, add three new parameters and give then key names and values | |
205 like:<br> | |
206 <img src="images/ltpda_training_1/topic2/lwb_interp_iplot.png" alt="Interpolate" border="3"> <br> | |
207 </li> | |
208 </ol> | |
209 </li> | |
210 </ol> | |
211 It should now be possible to run this pipeline and see a plot very similar to the one produced above. | |
212 </p> | |
213 </p> | |
214 | |
215 <br> | |
216 <br> | |
217 <table class="nav" summary="Navigation aid" border="0" width= | |
218 "100%" cellpadding="0" cellspacing="0"> | |
219 <tr valign="top"> | |
220 <td align="left" width="20"><a href="ltpda_training_topic_2_3.html"><img src= | |
221 "b_prev.gif" border="0" align="bottom" alt= | |
222 "Resampling a time-series AO"></a> </td> | |
223 | |
224 <td align="left">Resampling a time-series AO</td> | |
225 | |
226 <td> </td> | |
227 | |
228 <td align="right">Remove trends from a time-series AO</td> | |
229 | |
230 <td align="right" width="20"><a href= | |
231 "ltpda_training_topic_2_5.html"><img src="b_next.gif" border="0" align= | |
232 "bottom" alt="Remove trends from a time-series AO"></a></td> | |
233 </tr> | |
234 </table><br> | |
235 | |
236 <p class="copy">©LTP Team</p> | |
237 </body> | |
238 </html> |