Mercurial > hg > ltpda
comparison m-toolbox/html_help/help/ug/ltpda_training_topic_1_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>Basic math with AOs (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_1_3.html"><img src="b_prev.gif" border="0" align= | |
30 "bottom" alt="Making a time-series AO"></a> <a href= | |
31 "ltpda_training_topic_1_5.html"><img src="b_next.gif" border="0" align= | |
32 "bottom" alt="Saving and loading AOs"></a></td> | |
33 </tr> | |
34 </table> | |
35 | |
36 <h1 class="title"><a name="f3-12899" id="f3-12899"></a>Basic math with AOs</h1> | |
37 <hr> | |
38 | |
39 <p> | |
40 <p> | |
41 Most of the basic math operations supported by MATLAB have been implemented | |
42 as AO class methods. For example, suppose you want to add two AOs together, then you can do | |
43 </p> | |
44 <div class="fragment"><pre> | |
45 a = ao(1); | |
46 b = ao(2); | |
47 c = a+b | |
48 plot(c.hist) | |
49 </pre></div> | |
50 <p> | |
51 <i>Note: the units of the two AOs for addition and subtraction must be the same. You can't | |
52 add apples to oranges, but you can add dimensionless (empty units) to oranges.</i> | |
53 </p> | |
54 <p> | |
55 Some of the standard operators can act as modifiers. For example, if you want to square an AO: | |
56 </p> | |
57 <div class="fragment"><pre> | |
58 a = ao(2); | |
59 a.^2 | |
60 </pre></div> | |
61 <p> | |
62 will do the job. | |
63 </p> | |
64 <p> | |
65 The operators follow MATLAB rules whenever possible. So if you want to add | |
66 a single AO to a vector of AOs, you can. However, if you want to add two | |
67 vectors of AOs together, the two vectors must contain the same number of AOs. | |
68 For example, | |
69 </p> | |
70 <div class="fragment"><pre> | |
71 a = [ao(1) ao(2) ao(3)]; | |
72 b = ao(4); | |
73 c = a + b | |
74 </pre></div> | |
75 <p> | |
76 will work fine and result in <tt>b</tt> being added to each element of <tt>a</tt>. However, | |
77 </p> | |
78 <div class="fragment"><pre> | |
79 a = [ao(1) ao(2) ao(3)]; | |
80 b = [ao(4) ao(5)]; | |
81 c = a + b | |
82 </pre></div> | |
83 <p> | |
84 will give an error. | |
85 </p> | |
86 <p> | |
87 You can do all of this on the workbench as well, of course. | |
88 </p> | |
89 <p> | |
90 Try the following: | |
91 <ol> | |
92 <li>Start up the workbench, and/or open a new pipeline</li> | |
93 <li>Drag an <tt>ao</tt> constructor block to the canvas</li> | |
94 <li>Set the AO block to be constructed "From XY Values"</li> | |
95 <li>Duplicate the block two more times (<tt>ctrl/cmd-d</tt>)</li> | |
96 <li>Enter a number for the sampling ferquency <tt>fs</tt></li> | |
97 <li>Enter a vector the same length for the <tt>y</tt> value of each block</li> | |
98 <li>Drag a <tt>plus</tt> block to the canvas</li> | |
99 <li>You'll see that by default the "plus" block has two inputs. To add another input, | |
100 right-click on the block and choose "Add input" from the context menu</li> | |
101 <li>Connect each AO block to the plus block. The easiest way to do that is to | |
102 select the AO block (source) and then <tt>ctrl+left-click</tt> (<tt>cmd+left-click</tt> on Mac systems) on the plus (destination) block. You | |
103 can also drag a pipe from the output terminal of the AO blocks to the input terminals of the plus block | |
104 if you want to be explicit about which input ports are used.</li> | |
105 <li>Add an <tt>iplot</tt> block to the canvas and connect the output of the <tt>plus</tt> block to the input | |
106 of the <tt>iplot</tt> block. You should now have a pipeline something like:<br> | |
107 <img src="images/ltpda_training_1/topic1/ao_plus_eg.png" alt="AO plus example" border="1"> | |
108 </li> | |
109 <li>Execute the pipeline and you should see a plot something like the one below, depending on what | |
110 data values you gave to the <tt>ao</tt> constructors | |
111 <img src="images/ltpda_training_1/topic1/ao_plus_plot.png" alt="AO plus plot" border="1"></li> | |
112 </ol> | |
113 </p> | |
114 | |
115 | |
116 | |
117 | |
118 | |
119 </p> | |
120 | |
121 <br> | |
122 <br> | |
123 <table class="nav" summary="Navigation aid" border="0" width= | |
124 "100%" cellpadding="0" cellspacing="0"> | |
125 <tr valign="top"> | |
126 <td align="left" width="20"><a href="ltpda_training_topic_1_3.html"><img src= | |
127 "b_prev.gif" border="0" align="bottom" alt= | |
128 "Making a time-series AO"></a> </td> | |
129 | |
130 <td align="left">Making a time-series AO</td> | |
131 | |
132 <td> </td> | |
133 | |
134 <td align="right">Saving and loading AOs</td> | |
135 | |
136 <td align="right" width="20"><a href= | |
137 "ltpda_training_topic_1_5.html"><img src="b_next.gif" border="0" align= | |
138 "bottom" alt="Saving and loading AOs"></a></td> | |
139 </tr> | |
140 </table><br> | |
141 | |
142 <p class="copy">©LTP Team</p> | |
143 </body> | |
144 </html> |