<?xml version="1.0" encoding="utf-8" standalone="no"?>
<!DOCTYPE document PUBLIC "-//CNX//DTD CNXML 0.5 plus MathML//EN" "http://cnx.rice.edu/cnxml/0.5/DTD/cnxml_mathml.dtd">
<document xmlns="http://cnx.rice.edu/cnxml" xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/" id="None">
  <name>Arrays</name>
  <metadata>
  <md:version>1.1</md:version>
  <md:created>2004/06/25 15:44:01 GMT-5</md:created>
  <md:revised>2004/07/16 15:08:00.266 GMT-5</md:revised>
  <md:authorlist>
      <md:author id="NationalInstruments">
      <md:firstname>National</md:firstname>
      
      <md:surname>Instruments</md:surname>
      <md:email>certification@ni.com</md:email>
    </md:author>
  </md:authorlist>

  <md:maintainerlist>
    <md:maintainer id="lizzardg">
      <md:firstname>Elizabeth</md:firstname>
      
      <md:surname>Gregory</md:surname>
      <md:email>lizzardg@rice.edu</md:email>
    </md:maintainer>
    <md:maintainer id="mshiralkar05">
      <md:firstname>Malan</md:firstname>
      
      <md:surname>Shiralkar</md:surname>
      <md:email>mshiralkar05@hotmail.com</md:email>
    </md:maintainer>
    <md:maintainer id="harika">
      <md:firstname>Harika</md:firstname>
      
      <md:surname>Basana</md:surname>
      <md:email>ilsai@rice.edu</md:email>
    </md:maintainer>
    <md:maintainer id="NationalInstruments">
      <md:firstname>National</md:firstname>
      
      <md:surname>Instruments</md:surname>
      <md:email>certification@ni.com</md:email>
    </md:maintainer>
  </md:maintainerlist>
  
  <md:keywordlist>
    <md:keyword>National Instruments</md:keyword>
    <md:keyword>LabVIEW</md:keyword>
    <md:keyword>Arrays</md:keyword>
    <md:keyword>arrays</md:keyword>
  </md:keywordlist>

  <md:abstract>In this section, you will learn about arrays.</md:abstract>
</metadata>
  
  <content>
    <para id="para1">
      <term>Arrays</term> group data elements of the same type. An
      array consists of elements and dimensions. Elements are the data
      that make up the array. A dimension is the length, height, or
      depth of an array. An array can have one or more dimensions and
      as many as
      <m:math>
	<m:apply>
	  <m:minus/>
	  <m:apply>
	    <m:power/>
	      <m:cn>2</m:cn>
	      <m:cn>31</m:cn>
	  </m:apply>
	  <m:cn>1</m:cn>
	</m:apply>
      </m:math>
      elements per dimension, memory permitting.
    </para>   
    <para id="para2">
      You can build arrays of numeric, Boolean, path, string,
      waveform, and cluster data types. Consider using arrays when you
      work with a collection of similar data and when you perform
      repetitive computations. Arrays are ideal for storing data you
      collect from waveforms or data generated in loops, where each
      iteration of a loop produces one element of the array.
    </para>
    <para id="para3">
      You cannot create an array of arrays. However, you can create an
      array of <term>clusters</term>, where each cluster contains one
      or more arrays. Refer to <cnxn document="m12227">Clusters</cnxn> for
      more information about clusters.
    </para>
    <para id="para4">
      Array elements are ordered. An array uses an index so you can
      readily access any particular element. The index is zero-based,
      which means it is in the range
      <m:math>
	<m:cn>0</m:cn>
      </m:math>
      to
      <m:math>
	<m:apply>
	  <m:minus/>
	  <m:ci>n</m:ci>
	  <m:cn>1</m:cn>
	</m:apply>
      </m:math>, where
      <m:math>
	<m:ci>n</m:ci>
      </m:math>
      is the number of elements in the array. For example, if you
      create an array of the planets in the solar system,
      <m:math>
	<m:apply>
	  <m:eq/>
	  <m:ci>n</m:ci>
	  <m:cn>9</m:cn>
	</m:apply>
      </m:math>
      for the nine planets, so the index ranges from
      <m:math>
	<m:cn>0</m:cn>
      </m:math>
      to 
      <m:math>
	<m:cn>8</m:cn> </m:math>.  Earth is the third planet, so it
      has an index of
      <m:math>
	<m:cn>2</m:cn>
      </m:math>.
    </para>
    <section id="section1">
      <name>Creating Array Controls and Indicators</name>
      <para id="para5">
	To create an <code>array</code> control or indicator as shown
	in <cnxn target="f1"/>, select an <code>array</code> on the
	<code>Controls&gt;&gt;All Controls&gt;&gt;Array &amp; Cluster</code>
	palette, place it on the front panel, and drag a control or
	indicator into the <code>array</code> shell. If you attempt to
	drag an invalid control or indicator such as an XY graph into
	the array shell, you are unable to drop the control or
	indicator in the <code>array</code> shell.
      </para>
      <figure id="f1">
	<media type="image/png" src="aryex.png"/>
	<caption>
	  1. Index Display, 
	  2. Element Display
	</caption>
      </figure>
      <para id="para6">
	You must insert an object in the <code>array</code> shell
	before you use the <code>array</code> on the block
	diagram. Otherwise, the <code>array</code> terminal appears
	black with an empty bracket.
      </para>
      <section id="section2">
	<name>Two-Dimensional Arrays</name>
	<para id="para7">
	  A 2D array stores elements in a grid. It requires a column
	  index and a row index, both of which are zero-based, to
	  locate an element. <cnxn target="f2"/> shows a
	  <m:math>
	    <m:cn>6</m:cn>
	  </m:math>-column by
	  <m:math>	  
	    <m:cn>4</m:cn>
	  </m:math>-row 2D array, which contains 
	  <m:math>
	    <m:apply>
	      <m:eq/>
	      <m:apply>
		<m:times/>
		<m:cn>6</m:cn>
		<m:cn>4</m:cn>
	      </m:apply>
	      <m:cn>24</m:cn>
	    </m:apply>
	  </m:math> 
	  elements.
	</para>
	<figure id="f2">
	  <media type="image/png" src="2Darray.png"/>
	</figure>
	<para id="para8">
	  To add dimensions to an array one at a time, right-click the
	  index display and select <code>Add Dimension</code> from the
	  shortcut menu. You also can use the <code>Positioning</code>
	  tool to resize the index display until you have as many
	  dimensions as you want. <cnxn target="f3"/> is an example of
	  an uninitialized 2D array control.
	</para>
	<figure id="f3">
	  <media type="image/png" src="2dLVarray.png"/>
	</figure>
      </section>
    </section>
    <section id="section3">
      <name>Creating Array Constants</name>
      <para id="para9">
	You can create an <code>array constant</code> on the block
	diagram by selecting an <code>array constant</code> from the
	<code>Functions&gt;&gt;All Functions&gt;&gt;Array</code> palette, placing
	it on the block diagram, and dragging a constant into the
	array shell. <code>Array constants</code> are useful for
	passing data into a subVI.
      </para>
    </section>

  </content>
  
</document>
