Professional Documents
Culture Documents
An array can either resemble a vector or a matrix. As does a vector and a matrix, an array groups
similar pieces of data. An array consists of two different components, the elements (pieces of data) and the
dimension (the size of the array). Arrays may contain numeric, Boolean, path, string, waveform, and cluster
data types. They may be used as an indicator (output) or a control (input). Arrays are advantageous to use
when you are dealing with similar pieces of data and/or repetitive computations, which means that they are
ideal for storing waveform data and data from loop iterations with each array element being the loop
iteration value. The elements in the array are ordered or assigned a certain index. Arrays begin indexing
the elements at zero, so the first element will have an index of zero instead of one. This is very important to
remember when accessing data from an array.
1. Depending on the type of array you want to create, different methods in creating the array must be taken.
In the Front Panel, right click anywhere in an empty space and choose Controls Palette All-Controls
Array & Cluster Array
Page 36
ECE 100 Fundamentals of LabVIEW Programming
2. The array you create will have a control on the top-left side that will allow you to navigate through the
array. The number in the control box will indicate the index of the
element shown in the leftmost cell.
3. Notice when you first put the array on the front panel that it is empty.
You can determine your array type by inserting either a control or
indicator inside the array. For example, for a numerical indicator array:
On the Block Diagram of Procedure 1, Controls Palette Num Inds
Num Ind Place inside Array.
Question: Based on visual observation, how do you compare an Array control to an Array indicator
on the Front Panel?
Question: Based on visual observation, how do you compare an Array control to an Array indicator
on the Block Diagram?
Page 37
ECE 100 Fundamentals of LabVIEW Programming
5. You can control the viewing size of your array by dragging one of the corners where there is a little blue
box in either the vertical or horizontal direction. Thus, you can either make your one dimensional array
represent a column vector or a row vector, which will be important when performing mathematical
operations as arrays follow the same mathematical rules as do vectors and matrices. You may also notice
that the size of the array increases or decreases in increments of the current cell size.
7. To make an Array control or Array Indicator an Array constant, right click on the Array Icon; choose
ReplaceProgrammingArrayArray constant.
Page 38
ECE 100 Fundamentals of LabVIEW Programming
1. On the Block Diagram window, go to Functions palette and choose ProgrammingArray and drag
the array constant on the Block Diagram.
2. On the Functions palette, navigate to ProgrammingNumeric and drag and drop the Numeric
constant inside the array constant shell. You can resize the array element by dragging on the horizontal
direction at some point in the corner of the array.
3. Create and initialize two 1D array constants, containing six numeric elements, on the block diagram
similar to the array constants shown below.
4. Create a 1D array of numeric indicators on the front panel. Change the numeric type to a 32-bit integer.
Right-click on the array and select RepresentationI32.
5. Create a For-loop on the block diagram and place an add function inside the For-loop.
6. Wire one of the array constants into the For-loop and connect it to the x terminal of the add function.
The Block diagram should look like as shown on the next page.
Page 39
ECE 100 Fundamentals of LabVIEW Programming
7. Wire the other array constant into the For-loop and connect it to the y terminal of the add function.
Question: Why do we need to change the data representation of an Array Indicator in the Front
Panel to I-32? What does I-32 imply?
8. Your final block diagram and front panel should be similar to those shown below.
Page 40
ECE 100 Fundamentals of LabVIEW Programming
Block Diagram
Front Panel
9. Go to the front panel and run the VI. Note that each element in the array of numeric indicators is
populated with the sum of the corresponding elements in the two array constants. Save your VI as
Act5_3_1.VI
Question: After running the program, what is the resulting output? How did the VI work?
Question: Why do you think the VI run even the iteration constant is not set?
10. Try creating a VI as shown below with the following block diagram: Save your VI as Act5_3_2.VI.
Page 41
ECE 100 Fundamentals of LabVIEW Programming
Question: After running the program above, how many elements is the resulting array? Why do you
think that the program executes that resulting array?
11. Try creating a VI as shown below with the following block diagram: Save your VI as Act5_3_3.VI.
Question: After running the program above, how many elements is the resulting array? How does
the program execute the resulting array?
Page 42
ECE 100 Fundamentals of LabVIEW Programming
1. Create a VI that would perform arithmetic operations (add, subtract, multiply and divide), as well as
arrays. Design your front panel as if it will look like a scientific calculator for arrays and matrices. It would be
good if the user is informed whether an operation is invalid and why. Create separate VIs for arrays
(ArrayCalculator.vi) and matrices (MatrixCalculator.vi)
2. Two more commonly done operations on matrices, specifically on square matrices, are finding
determinants and finding the inverse. Using arrays create a VI that would evaluate the determinant of a 2D
square array as user input; call this VI as Determinants.vi. Create a separate VI which will evaluate the
inverse of a 2D square array of numeric data using co-factors and expansion by minors; call the VI as
InverseMatrix.vi. Check your results using matrices and matrix functions (Functions >> Mathematics >>
Linear Algebra)
V. ASSESSMENT TASKS
2. How does addition, subtraction, multiplication and division of arrays in LabVIEW works? State
mathematically on how to perform operations in arrays.
VI. CONCLUSION
Page 43