1 / 21

EET 2259 Unit 9 Arrays

EET 2259 Unit 9 Arrays. Read Bishop, Sections 6.1 to 6.3. Homework #9 and Lab #9 due next week. Quiz #5 next week. Arrays and Clusters.

Download Presentation

EET 2259 Unit 9 Arrays

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. EET 2259 Unit 9Arrays • Read Bishop, Sections 6.1 to 6.3. • Homework #9 and Lab #9 due next week. • Quiz #5 next week

  2. Arrays and Clusters • An array is a variable-sized collection of data elements that are all of the same data type (such as floating point, integer, string, or Boolean). • A cluster is a fixed-sized collection of data elements of mixed data types. (Bishop, p. 289)

  3. Usefulness of Arrays • Arrays are useful when you have a collection of data points that you wish to plot or a collection of similar items that you wish to manipulate as a group. (Bishop, p. 289)

  4. Dimension of an Array • Every array has a dimension. • We’ll deal primarily with one-dimensional arrays, which you can think of as a list of items. • Example: a list of student grades on a single assignment in a class: 90, 77, 82, 95, 60, : (Bishop, p. 289)

  5. Creating an Array of Controls or Indicators • To create an array of controls or indicators: • Place an array shell on the front panel from the Controls >> Modern >> Array, Matrix & Cluster palette. • Place a control or indicator inside that array shell. (Bishop, p. 290)

  6. Displaying Multiple Elements • To display more than one element of an array on the front panel, drag the array’s resizing handles until the desired number of elements are visible. • The box to the left shows the index of the first visible element. (Bishop, p. 290)

  7. Index of an Array’s Elements • Each element in an array can be referred to by its index, which is an integer showing the element’s position in the array. • In LabVIEW, indexes are zero-based. So the first element in a one-dimensional array has an index of 0, the second element has an index of 1, and so on. • If a one-dimensional array contains n elements, the last element has an index of n1. (Bishop, p. 289)

  8. Array Terminal on Block Diagram • When an array shell is first created, its terminal on the block diagram is outlined in black and shows no data type. • After the array’s data type has been defined by placing an item in the shell, the terminal changes color to show the data type. (Bishop, p. 292)

  9. Array Wires on Block Diagram • On the block diagram, a wire carrying an array of data values appears thicker than a wire carrying a single data value. (Bishop, p. 292)

  10. Arrays & the DAQ Assistant • When you use the DAQ Assistant to perform a digital input task, the DAQ Assistant produces an array of Boolean values. • And when you use the DAQ Assistant to perform a digital output task, you must provide the DAQ Assistant with an array of Boolean values.

  11. Creating Arrays with Loops • A feature called auto-indexing on For Loops and While Loops lets you tell LabVIEW to create arrays automatically when the loops run. • To enable or disable auto-indexing, right-click a tunnel on a loop’s border and select Enable Indexing or Disable Indexing. (Bishop, p. 293)

  12. Removing Elements from an Array • To manually remove an element on the front panel, right-click the element and select Data Operations > Delete Element. • To manually remove all elements, right-click the array’s index display and select Data Operations > Empty Array.

  13. Array Functions • The Functions >> Programming >> Arraypalette provides many functions for working with arrays, including: • Array Size • Index Array • Array Subset • Build Array • Initialize Array • Delete From Array

  14. Array Size • The Array Size function takes an array as its input. For its output, it returns the number of elements in that array. • The input array can be of any data type (numeric, Boolean, string). The output returned by the function is an integer. (Bishop, p. 297)

  15. Index Array • The Index Array function takes an array and a number (called index) as its inputs. For its output, it returns the element at the index position in that array. (Bishop, p. 302)

  16. Array Subset • The Array Subset function takes an array and two numbers (one called index and one called length) as its inputs. For its output, it returns a new array containing the portion of the original array starting at index and containing length elements. (Bishop, p. 301)

  17. Build Array • The Build Array function takes arrays and/or individual data values as its inputs. For its output, it returns an array containing all elements from the input arrays and values. • The input arrays and data values must be of the same type as each other (numeric, Boolean, string). The output returned by the function is an array of that same type. (Bishop, p. 300)

  18. Initialize Array • The Initialize Array function takes an integer n and a data value as its inputs. For its output, it returns a newly created array containing n elements, each of which is equal to the specified data value. • The input data value can be of any data type (numeric, Boolean, string). The output returned by the function is an array of that same type. (Bishop, p. 298)

  19. Delete From Array • The Delete From Array function takes an array and two numbers (one called index and one called length) as its inputs. For its output, it returns a new array equal to the original array but without the length elements starting at index. • The input data value can be of any data type (numeric, Boolean, string). The output returned by the function is an array of that same type.

  20. Two-Dimensional Array • Think of a two-dimensional array as a set of items arranged in a table. • Example: a table of student grades on all of the assignments in a class: 90, 86, 93, … 77, 92, 68, … 82, 84, 82, … 95, 89, 94, … 60, 80, 75, … : : :

  21. Higher-Dimensional Arrays • Three-dimensional and higher-dimensional arrays are also possible, but we’ll concentrate on one-dimensional and two-dimensional arrays.

More Related