view m-toolbox/html_help/help/ug/ltpda_training_topic_1_4.html @ 36:5eb86f6881ef database-connection-manager

Remove commented-out code
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Mon, 05 Dec 2011 16:20:06 +0100
parents f0afece42f48
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>Basic math with AOs (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_1_3.html"><img src="b_prev.gif" border="0" align=
      "bottom" alt="Making a time-series AO"></a>&nbsp;&nbsp;&nbsp;<a href=
      "ltpda_training_topic_1_5.html"><img src="b_next.gif" border="0" align=
      "bottom" alt="Saving and loading AOs"></a></td>
    </tr>
  </table>

  <h1 class="title"><a name="f3-12899" id="f3-12899"></a>Basic math with AOs</h1>
  <hr>
  
  <p>
	<p>
  Most of the basic math operations supported by MATLAB have been implemented 
  as AO class methods. For example, suppose you want to add two AOs together, then you can do
</p>
<div class="fragment"><pre>
    a = ao(1);
    b = ao(2);
    c = a+b
    plot(c.hist)
</pre></div>
<p>
  <i>Note: the units of the two AOs for addition and subtraction must be the same. You can't 
  add apples to oranges, but you can add dimensionless (empty units) to oranges.</i>
</p>
<p>
  Some of the standard operators can act as modifiers. For example, if you want to square an AO:
</p>
<div class="fragment"><pre>
    a = ao(2);
    a.^2
</pre></div>
<p>
  will do the job.
</p>
<p>
  The operators follow MATLAB rules whenever possible. So if you want to add 
  a single AO to a vector of AOs, you can. However, if you want to add two 
  vectors of AOs together, the two vectors must contain the same number of AOs. 
  For example,
</p>
<div class="fragment"><pre>
    a = [ao(1) ao(2) ao(3)];
    b = ao(4);
    c = a + b
</pre></div>
<p>
  will work fine and result in <tt>b</tt> being added to each element of <tt>a</tt>. However,
</p>
<div class="fragment"><pre>
    a = [ao(1) ao(2) ao(3)];
    b = [ao(4) ao(5)];
    c = a + b
</pre></div>
<p>
  will give an error.
</p>
<p>
  You can do all of this on the workbench as well, of course.
</p>
<p>
  Try the following:
  <ol>
    <li>Start up the workbench, and/or open a new pipeline</li>
    <li>Drag an <tt>ao</tt> constructor block to the canvas</li>
    <li>Set the AO block to be constructed "From XY Values"</li>
    <li>Duplicate the block two more times (<tt>ctrl/cmd-d</tt>)</li>
    <li>Enter a number for the sampling ferquency <tt>fs</tt></li>
    <li>Enter a vector the same length for the <tt>y</tt> value of each block</li>
    <li>Drag a <tt>plus</tt> block to the canvas</li>
    <li>You'll see that by default the "plus" block has two inputs. To add another input, 
    right-click on the block and choose "Add input" from the context menu</li>
    <li>Connect each AO block to the plus block. The easiest way to do that is to 
      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
      can also drag a pipe from the output terminal of the AO blocks to the input terminals of the plus block
    if you want to be explicit about which input ports are used.</li>
    <li>Add an <tt>iplot</tt> block to the canvas and connect the output of the <tt>plus</tt> block to the input 
      of the <tt>iplot</tt> block. You should now have a pipeline something like:<br>      
      <img src="images/ltpda_training_1/topic1/ao_plus_eg.png" alt="AO plus example" border="1">
    </li>
    <li>Execute the pipeline and you should see a plot something like the one below, depending on what 
      data values you gave to the <tt>ao</tt> constructors
    <img src="images/ltpda_training_1/topic1/ao_plus_plot.png" alt="AO plus plot" border="1"></li>
  </ol>
</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_1_3.html"><img src=
      "b_prev.gif" border="0" align="bottom" alt=
      "Making a time-series AO"></a>&nbsp;</td>

      <td align="left">Making a time-series AO</td>

      <td>&nbsp;</td>

      <td align="right">Saving and loading AOs</td>

      <td align="right" width="20"><a href=
      "ltpda_training_topic_1_5.html"><img src="b_next.gif" border="0" align=
      "bottom" alt="Saving and loading AOs"></a></td>
    </tr>
  </table><br>

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