comparison m-toolbox/html_help/help/ug/interp_content.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 <h2>Description</h2>
2 <p>
3 Interpolation of data can be done in the LTPDA Toolbox by means of
4 <a href="matlab:doc('ao/interp')"><tt>interp</tt></a>.
5 This function interpolates the values in the input AO(s) at new values specified by the
6 input parameter list.
7 </p>
8 <p>
9 <a href="matlab:doc('ao/interp')"><tt>Interp</tt></a> overloads <tt>interp1</tt> function of
10 Matlab Signal Processing Toolbox for AOs.
11 </p>
12 <br>
13 <br>
14 <h2>Syntax</h2>
15 </p>
16 <div class="fragment"><pre>
17 <br>
18 b = interpolate(a, pl)
19 </pre>
20 </div>
21 <h2>Parameters</h2>
22 <p>
23 The following parameters can be set in the method:
24 <ul>
25 <li> <tt>vertices</tt> - specify the new vertices to interpolate on </li>
26 <li> <tt>method</tt> - four methods are available for interpolating data</li>
27 <ul>
28 <li> 'nearest'- nearest neighbor interpolation </li>
29 <li> 'linear' - linear interpolation </li>
30 <li> 'spline' - spline interpolation (default option) </li>
31 <li> 'cubic' - shape-preserving piecewise cubic interpolation </li>
32 </ul>
33 </ul>
34 For details see <tt>interp1</tt> help of Matlab.
35 </p>
36 <p>
37 <h2>Examples</h2>
38 </p>
39 <p>
40 1. Interpolation of a sequence of random data at original sampling rate of 1 Hz
41 by a factor of 10 with no initial phase.
42 </p>
43 <div class="fragment"><pre>
44 <br>
45 <span class="comment">% Signal generation</span>
46 pl = plist(<span class="string">'tsfcn'</span>,<span class="string">'sin(2*pi*1.733*t)'</span>,...
47 <span class="string">'fs'</span>,1,<span class="string">'nsecs'</span>,10,...
48 <span class="string">'yunits'</span>,<span class="string">'V'</span>);
49 x = ao(pl);
50 <span class="comment">% Interpolate on a new time vector</span>
51 t = linspace(0, x.data.nsecs - 1/x.data.fs, 2*len(x));
52 pl_spline = plist(<span class="string">'vertices'</span>,t);
53 pl_nearest = plist(<span class="string">'vertices'</span>,t,<span class="string">'method'</span>,<span class="string">'nearest'</span>);
54 x_spline = interp(x,pl_spline);
55 x_nearest = interp(x,pl_nearest);
56 iplot([x x_spline x_nearest], plist(<span class="string">'Markers'</span>, {<span class="string">'x'</span>, <span class="string">'o'</span>, <span class="string">'+'</span>}, ...
57 <span class="string">'LineColors'</span>, {<span class="string">'k'</span>, <span class="string">'r'</span>}));
58 </pre>
59 </div>
60 <br>
61 <br>
62 <img src="images/interp.png" alt="Interpolate" border="0">