view m-toolbox/html_help/help/ug/ltpda_training_topic_2_1.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 source

<!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>Downsampling 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.html"><img src="b_prev.gif" border="0" align=
      "bottom" alt="Topic 2 - Pre-processing of data"></a>&nbsp;&nbsp;&nbsp;<a href=
      "ltpda_training_topic_2_2.html"><img src="b_next.gif" border="0" align=
      "bottom" alt="Upsampling a time-series AO"></a></td>
    </tr>
  </table>

  <h1 class="title"><a name="f3-12899" id="f3-12899"></a>Downsampling a time-series AO</h1>
  <hr>
  
  <p>
	
Downsampling reduces the sampling rate of the input AOs by an integer factor, which can be very useful for example to reduce data load.

<p>The <tt>downsample</tt> method takes 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 'factor' -->
      <tr valign="top">
        <td bgcolor="#f3f4f5">
          <p><tt>FACTOR</tt></p>
        </td>
        <td bgcolor="#f3f4f5">
          <p>The decimation factor [by default is 1: no downsampling] (must be an integer)</p>
        </td>
      </tr>
      <!-- Key 'offset' -->
      <tr valign="top">
        <td bgcolor="#f3f4f5">
          <p><tt>OFFSET</tt></p>
        </td>
        <td bgcolor="#f3f4f5">
          <p>The sample offset for where the downsampling starts counting. By default, this value is
        zero so it starts counting from the first sample.</p>
        </td>
      </tr>
    </tbody>
  </table>
</p>
<h2><a name="example1">Example 1</h2>
<p>
  First we'll create a time-series of random white noise at 10Hz. To do that,
  define a <tt>plist</tt> with the key/value pairs shown below, and pass these
  to the <tt>ao</tt> constructor. If you're using the workbench, add an <tt>ao</tt>
  constructor block to the canvas and select the parameter set "From Time-series Function" and
  set the parameters as they are in the <tt>plist</tt> below.
</p>
<div class="fragment"><pre>
    <span class="comment">% create an AO of random data with fs = 10 Hz;</span>
    pl      = plist(<span class="string">'name'</span>, <span class="string">'None'</span>, ...
                    <span class="string">'tsfcn'</span>,  <span class="string">'randn(size(t))'</span>, <span class="keyword">...</span>
                    <span class="string">'fs'</span>,      10, <span class="keyword">...</span>
                    <span class="string">'yunits'</span>, <span class="string">'m'</span>, <span class="keyword">...</span>
                    <span class="string">'nsecs'</span>,   10);
    x       = ao(pl); <span class="comment">% create AO</span>
  </pre>
</div>
<p>
  Now we will downsample this data by a factor 5 to 2Hz. We use the method <tt>ao/downsample</tt> and set
  the downsample factor in the <tt>plist</tt> as shown below.
</p>
<div class="fragment"><pre>
    pl_down = plist(<span class="string">'factor'</span>, 5); <span class="comment">% add the decimation factor</span>
    x_down  = downsample(x, pl_down); <span class="comment">% downsample the input AO, x</span>
    iplot(x, x_down) <span class="comment">% plot original,x, and decimated,x_down, AOs</span>
  </pre>
</div>
<img src="images/ltpda_training_1/topic2/down1.png" alt="Downsample" border="3">
<br>
<br>
<h2><a name="example2">Example 2</h2>
<p>
  The <tt>downsample</tt> method takes an 'offset' key which controls where the counting starts. The default is
  to output every Nth sample starting with the first. The 'offset' key tells <tt>downsample</tt> to start the counting
  from a sample other than the first. The example
  below outputs every 4th sample starting from sample 10.
</p>
<div class="fragment"><pre>
    pl_downoff = plist(<span class="string">'factor'</span>, 4,<span class="string">'offset'</span>,10); <span class="comment">% add decimation factor and offset parameter</span>
    x_downoff  = downsample(x, pl_downoff); <span class="comment">% downsample the input AO, x</span>
    iplot(x, x_downoff) <span class="comment">% plot original,x, and decimated,x_downoff, AOs</span>
  </pre>
</div>
<img src="images/ltpda_training_1/topic2/down2.png" alt="Downsample" border="3">



  </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.html"><img src=
      "b_prev.gif" border="0" align="bottom" alt=
      "Topic 2 - Pre-processing of data"></a>&nbsp;</td>

      <td align="left">Topic 2 - Pre-processing of data</td>

      <td>&nbsp;</td>

      <td align="right">Upsampling a time-series AO</td>

      <td align="right" width="20"><a href=
      "ltpda_training_topic_2_2.html"><img src="b_next.gif" border="0" align=
      "bottom" alt="Upsampling a time-series AO"></a></td>
    </tr>
  </table><br>

  <p class="copy">&copy;LTP Team</p>
</body>
</html>