diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/m-toolbox/html_help/help/ug/ltpda_training_topic_2_4.html	Wed Nov 23 19:22:13 2011 +0100
@@ -0,0 +1,238 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+   "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
+
+<html lang="en">
+<head>
+  <meta name="generator" content=
+  "HTML Tidy for Mac OS X (vers 1st December 2004), see www.w3.org">
+  <meta http-equiv="Content-Type" content=
+  "text/html; charset=us-ascii">
+
+  <title>Interpolation of a time-series AO (LTPDA Toolbox)</title>
+  <link rel="stylesheet" href="docstyle.css" type="text/css">
+  <meta name="generator" content="DocBook XSL Stylesheets V1.52.2">
+  <meta name="description" content=
+  "Presents an overview of the features, system requirements, and starting the toolbox.">
+  </head>
+
+<body>
+  <a name="top_of_page" id="top_of_page"></a>
+
+  <p style="font-size:1px;">&nbsp;</p>
+
+  <table class="nav" summary="Navigation aid" border="0" width=
+  "100%" cellpadding="0" cellspacing="0">
+    <tr>
+      <td valign="baseline"><b>LTPDA Toolbox</b></td><td><a href="../helptoc.html">contents</a></td>
+
+      <td valign="baseline" align="right"><a href=
+      "ltpda_training_topic_2_3.html"><img src="b_prev.gif" border="0" align=
+      "bottom" alt="Resampling a time-series AO"></a>&nbsp;&nbsp;&nbsp;<a href=
+      "ltpda_training_topic_2_5.html"><img src="b_next.gif" border="0" align=
+      "bottom" alt="Remove trends from a time-series AO"></a></td>
+    </tr>
+  </table>
+
+  <h1 class="title"><a name="f3-12899" id="f3-12899"></a>Interpolation of a time-series AO</h1>
+  <hr>
+  
+  <p>
+	<p>
+  The <tt>ao</tt> class has a method for interpolating data using different forms of interpolation. This method is
+  called <tt>ao/interp</tt>.
+</p>
+<p>
+  To configure <tt>ao/interp</tt>, use the following parameters:
+  <table cellspacing="0" class="body" cellpadding="2" border="0" width="80%">
+    <colgroup>
+      <col width="25%"/>
+      <col width="75%"/>
+    </colgroup>
+    <thead>
+      <tr valign="top">
+        <th class="categorylist">Key</th>
+        <th class="categorylist">Description</th>
+      </tr>
+    </thead>
+    <tbody>
+      <!-- Key 'Vertices' -->
+      <tr valign="top">
+        <td bgcolor="#f3f4f5">
+          <p><tt>VERTICES</tt></p>
+        </td>
+        <td bgcolor="#f3f4f5">
+          <p>A new set of vertices (relative to the t0) on which to resample.</p>
+        </td>
+      </tr>
+      <!-- Key 'method' -->
+      <tr valign="top">
+        <td bgcolor="#f3f4f5">
+          <p><tt>METHOD</tt></p>
+        </td>
+        <td bgcolor="#f3f4f5">
+          <p>The method by which to interpolate. Choose from
+            <ul>
+              <li>'nearest' - nearest neighbour</li>
+              <li>'linear'  - linear interpolation</li>
+              <li>'spline'  - for spline interpolation</li>
+              <li>'cubic'   - for cubic interpolation</li>
+          </ul></p>
+        </td>
+      </tr>
+    </tbody>
+  </table>
+</p>
+<h2>Example</h2>
+<p>
+  Here we will interpolate a sinusoid singal on to a new time-grid. The result will be to increase the
+  sample rate by a factor 2.
+</p>
+<p>
+  First we create a time-series ao:
+</p>
+<div class="fragment"><pre>
+    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>);
+    x  = ao(pl);
+  </pre>
+</div>
+<p>
+  Then we create the new time-grid we want to resample on to.
+</p>
+<div class="fragment"><pre>
+   tt   = linspace(0, x.nsecs - 1/x.fs, 2*(x.len));
+  </pre>
+</div>
+<p>
+  And finally we can apply our new time-grid to the data using <tt>interp</tt>. We test two of the available interpolation methods:
+</p>
+<div class="fragment"><pre>
+    pl_spline  = plist(<span class="string">'vertices'</span>,tt);
+    pl_nearest = plist(<span class="string">'vertices'</span>,tt,<span class="string">'method'</span>,<span class="string">'nearest'</span>);
+    x_spline   = interp(x,pl_spline);
+    x_nearest  = interp(x,pl_nearest);
+    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>}, ...
+    <span class="string">'LineColors'</span>, {<span class="string">'k'</span>, <span class="string">'r'</span>, <span class="string">'g'</span>}, ...
+    <span class="string">'XRanges'</span>, [0 1]));
+  </pre>
+</div>
+<img src="images/ltpda_training_1/topic2/interp.png" alt="Interpolate" border="3">
+<br>
+<br>
+<p>
+  To do the same activity on the workbench, we can use a pipeline like:
+</p>
+<img src="images/ltpda_training_1/topic2/lwb_interp_1.png" alt="Interpolate" border="3">
+<p>
+  This teaches some important aspects of the use of the workbench, so it's worth stepping through its construction slowly.
+</p>
+<p>
+  To build this pipeline:
+  <ol>
+    <li>Create a new empty canvas</li>
+    <li>Add two MATLAB Expression Blocks:
+      <ol>
+        <li>Right-click on the canvas and choose "Add Block...->MATBlock". A <tt>MATBlock</tt> is a block which can
+        evaluate any valid MATLAB expression and pass that to further blocks via its single output.</li>
+        <li>Select the block, then change its name in the block
+  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>
+        <li>Double-click the block to get a pop-up dialog where you can enter the MATLAB expression. In this case
+        just enter the value 20.</li>
+        <li>Select this 'fs' block and hit <tt>ctrl-d</tt> (<tt>cmd-d</tt> on OS X) to duplicate the block.</li>
+        <li>Select the new block and change its name to 'nsecs'</li>
+        <li>Double-click the 'nsecs' block to change its expression. Enter the value 10.</li>
+      </ol>
+    </li>
+    <li>Next we need some additional blocks. Add an <tt>ao</tt> block, two <tt>ao/interp</tt> blocks, an
+      <tt>ao/x</tt> block, and an <tt>ao/iplot</tt> block.
+    </li>
+    <li>Connect up the blocks as shown on the pipeline above.
+      <table cellspacing="0" class="note" summary="Note" cellpadding="5" border="1">
+        <tr width="90%">
+          <td>
+            To add inputs (or outputs) to a block, right-click on the block and choose "Add input".
+          </td>
+        </tr>
+      </table>
+      <table cellspacing="0" class="note" summary="Note" cellpadding="5" border="1">
+        <tr width="90%">
+          <td>
+            Double-click an LTPDA Block to get a dialog box to enter a new name for the block.
+          </td>
+        </tr>
+      </table>
+      <table cellspacing="0" class="note" summary="Note" cellpadding="5" border="1">
+        <tr width="90%">
+          <td>
+            To set the color of the pipes eminating from a particular block, right-click on the block
+            and choose "Set output pipe color" from the context menu. You can also set the color of
+            individual pipes by right-clicking on a pipe and choosing "Set color" from the context menu.
+          </td>
+        </tr>
+      </table>
+    </li>
+    <li>Next we need to set the various properties of each block. Follow these steps:
+      <ol>
+        <li>Set the properties of the AO block to look like:<br>
+          <img src="images/ltpda_training_1/topic2/lwb_interp_ao_props.png" alt="Interpolate" border="3">
+          <table cellspacing="0" class="note" summary="Note" cellpadding="5" border="1">
+            <tr width="90%">
+              <td>
+                The single quotes around the <tt>TSFCN</tt> value are not strictly necessary, but it can
+                avoid problems, for example in the case you have a variable <tt>t</tt> already defined in the MATLAB
+                workspace.
+              </td>
+            </tr>
+          </table>
+        </li>
+        <li>
+          Set the properties of the first interpolate block (a_spline) to look like:<br>
+          <img src="images/ltpda_training_1/topic2/lwb_interp_ao_interp1.png" alt="Interpolate" border="3"> <br>
+          Notice that here we have used the keywords <tt>PORT_1</tt> and <tt>PORT_2</tt> to build the expression. These
+          refer to the ports of that block, and are connected to the MATLAB Expression Blocks which represent the values
+          we are interested in.
+        </li>
+        <li>
+          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
+          is then passed to the next interpolation block where we use the values as the vertices for the next
+          interpolation step, thus ensuring that the two interpolations are done on the same grid.
+        </li>
+        <li>
+          Set the properties of the second interpolate block (a_near) to look like:<br>
+          <img src="images/ltpda_training_1/topic2/lwb_interp_ao_interp2.png" alt="Interpolate" border="3"> <br>
+        </li>
+        <li>
+          Finally, for the <tt>iplot</tt> block, add three new parameters and give then key names and values
+          like:<br>
+          <img src="images/ltpda_training_1/topic2/lwb_interp_iplot.png" alt="Interpolate" border="3"> <br>
+        </li>
+      </ol>
+    </li>
+  </ol>
+  It should now be possible to run this pipeline and see a plot very similar to the one produced above.
+</p>
+  </p>
+
+  <br>
+  <br>
+  <table class="nav" summary="Navigation aid" border="0" width=
+  "100%" cellpadding="0" cellspacing="0">
+    <tr valign="top">
+      <td align="left" width="20"><a href="ltpda_training_topic_2_3.html"><img src=
+      "b_prev.gif" border="0" align="bottom" alt=
+      "Resampling a time-series AO"></a>&nbsp;</td>
+
+      <td align="left">Resampling a time-series AO</td>
+
+      <td>&nbsp;</td>
+
+      <td align="right">Remove trends from a time-series AO</td>
+
+      <td align="right" width="20"><a href=
+      "ltpda_training_topic_2_5.html"><img src="b_next.gif" border="0" align=
+      "bottom" alt="Remove trends from a time-series AO"></a></td>
+    </tr>
+  </table><br>
+
+  <p class="copy">&copy;LTP Team</p>
+</body>
+</html>