view m-toolbox/html_help/help/ug/resample_content.html @ 39:11e3ed9d2115 database-connection-manager

Implement databases listing in database connection dialog
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Mon, 05 Dec 2011 16:20:06 +0100
parents f0afece42f48
children
line wrap: on
line source

<h2>Description</h2>
<p>
  Resampling is the process of changing the sampling rate of data. <a href="matlab:doc('ao/resample')"><tt>Resample</tt></a>
  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.
</p>
<h2>Syntax</h2>
<div class="fragment"><pre>
    <br>
    b = resample(a, pl)
  </pre>
</div>
<h2>Parameters</h2>
<p>  The following parameters can be set:
  <ul>
    <li> <tt>fsout</tt> - specify the desired output frequency (must be positive and integer)</li>
    <li> <tt>filter</tt> - specified filter applied to the input, <tt>a</tt>, in the resampling process</li>
  </ul>
</p>
<p>
  <h2>Examples</h2>
</p>
<p>
  2. Resampling a sequence of random data at original sampling rate of 1 Hz at an output sampling of 50 Hz.
</p>
<div class="fragment"><pre>
  <br>
    <span class="comment">% create an AO of random data with fs = 10 Hz</span>
    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);
    x     = ao(pl);
    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>
    iplot(x, y)                              <span class="comment">% plot original and resampled data</span>
  </pre>
</div>
<br>
<br>
<img src="images/resample1.png" alt="Resample">
<br>
<br>
<br>
<p>
  1. Resampling a sequence of random data at original sampling rate of 10 Hz at an output sampling of 1 Hz with
  a filter defined by the user.
</p>
<div class="fragment"><pre>
  <br>
    <span class="comment">% create an AO of random data with fs = 10 Hz</span>
    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>);
    x  = ao(pl)	
    
    <span class="comment">% filter definition</span>
    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);
    f        = mfir(plfilter)
    
    <span class="comment">% resampling</span>
    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>
    y  = resample(x, pl);  <span class="comment">% resample the input AO (x) to obtain the resampled output AO (y)</span>
    iplot(x, y)            <span class="comment">% plot original and resampled data</span>
  </pre>
</div>
<br>
<br>
<img src="images/resample2.png" alt="Resample" border="0">