Create the 1-D Array with 10 elements as shown in the Front Panel Below
Ask Expert

Be Prepared For The Toughest Questions

Practice Problems

Create the 1-D Array with 10 elements as shown in the Front Panel Below

1. Open LabVIEW and Create a Blank VI. For this exercise you will create the VI shown at the back of the document. This VI uses the array functions discussed earlier. The Front Panel and VI are labeled such that the Controls and Indicator can be easily matched to the Block Diagram.

2. Enable the context help. This will provide you with information on the VI(s) and the terminal labels and locations.

3. After the code for each function is created. Run it to observe how it works. Once an understanding is gained, move on to the next function shown in the sample VI.

4. All the array functions are located in the Functions>>Programming>>Array palette.

5. The functions covered include:

a. Array Size

i. Create the 1-D Array with 10 elements as shown in the Front Panel Below. Place an Array Size function on the Block Diagram.

ii. Wire the 10 Element array to the Array Size function and wire an indicator to the function output.

iii. Fill in the array with values

iv. Run the code and observe the indicator output. It should show a value of 10 indicating the array size.

b. Initialize Array - For this demo, you will create and initialize a 2-D Array. As shown in the front panel example supplied.

i. Place an Initialize Array function on the Block Diagram.

ii. To the element terminal, wire a numeric value to which the array will be initialized.

iii. To the first dimension terminal wire a constant specifying the number of rows the array will contain.

iv. Mouse over the function to show the resize handle. Using the resize handles expand the function to obtain a second dimension terminal. 

v. Wire a constant to the second dimension terminal. This number specifies the number of columns the array will contain.

vi. Wire an indicator to the output of the function. The indicator should appear as an array.

vii. Run the code and verify that a 2-D array with the dimension specified was created on the Front Panel, as shown in the example below.

c. Build Array - In this example, we will use the Build Array function to append a scalar value to the top of an existing array.

i. On the Front Panel, create a small 1-D Array. Load the array with scalar values.

ii. As in the example at the back of the document, place a Build Array function on the Block Diagram. 

iii. Wire a constant value to terminal one. 

iv. Expand the build array function to include two terminals.

v. Wire the array you created to the second terminal of the Build Array function.

vi. Wire an indicator to the Build Array function output. The indicator should appear as an array.

vii. Run the code. Verify the presence of a new array on the Front Panel containing the array you created with the constant appended to the top.

viii. Place a second Build Array function on the Block Diagram and expand it to contain two terminals. Wire constants to the terminals and wire and indicator to the output.

ix. Run the code. Verify that a 1-D array with two elements was created.

d. Array Subset

i. Place an Array Subset function on the Block Diagram (as shown in the diagram).

ii. Wire the 1-D Array created for the Array Size Function to the Array Subset function array input terminal. Wire a constant to the index terminal. This specifies the index in the array at which you want to start. 

iii. To the length terminal wire another constant. This will specify the number of elements to copy from the index specified on the previous terminal.

iv. Wire an indicator to the output of the function. The indicator should appear as an array.

v. Run the code. Verify the presence of a smaller array on the Front Panel containing the data elements specified by the constant you wired to the Array Subset function. (note the index specified is ‘0’ based).

e. Index Array

i. On the Block Diagram, place an Index Array function. 

ii. Wire the 1D Array from the Array subset function to the n-dimension Array terminal.

iii. Wire a control to the index terminal.  This control will be used to select the array element of interest.

iv. Wire an indicator to the output of the Index Array function. The indicator should appear as a scalar indicator.

v. Run the code and verify that the number displayed corresponds to the row index you specified. 

f. Modifying arrays in loops using initialize and index array functions.

i. Place an Initialize Array function on the block diagram and wire constants with values 3 and 10 to the element and dimension terminals respectively.  This will create a 10 element array with a ‘3’ in each location.

ii. Place a For-Loop on the Block Diagram. Set the For Loop to execute 10 times.

iii. Inside the For-Loop place an Index Array. Place a multiplication and add function inside the loop and wire as shown on the provided example.

iv. Wire the output of the Initialize Array function to the For-Loop to create a tunnel. Disable Indexing so the entire array will be passed into the loop on the first iteration.  

v. Using the For-Loop iterator terminal, index through the array. As the loop runs, the iterator terminal will enable the Index Array function to select each element of the array, one at a time, to be added to a random number between 1 and 2. Wire an indicator to the output of the addition. Enable indexing on the For-Loop tunnel. The indicator should appear as an array.

vi. Run the code and verify that the output array contains data that is a product of the array elements and iterator.

g. Search 1-D Array

i. Place a Search 1D Array function on the Block Diagram (as shown in the diagram).

ii. Wire the 1-D Array created for the Array Size Function to the Search 1D Array function array input terminal. Wire a constant to the index terminal. 

iii. Create an indicator on the output of the search 1D Array function. The indicator should appear as a standard scalar indicator.

iv. Wire a constant to the element terminal specifying the value for which you are searching. 

v. To the index terminal, wire a constant. This specified the point in the array from which to start searching.

vi. Run the code and verify that the index returned correspond to the index in the array where the value resides

h. Replace Array Subset

i. Using the Initialize Array Function create a 2 x 2 Array with a value of 7 in each cell.

ii. Place a Replace Array Subset function on the block diagram as shown. Wire the 2D Array created for the Initialize Array Function exercise (para b) to the Array input on the Replace Array Subset function.  (note that the creation of an additional index terminal on the function when you attached a 2D array)

iii. Wire a constant with a value of 1 to the row index terminal.

iv. Wire a constant with a value of 3 to the column index terminal.

v. Wire the 2 x 2 Array with values of 7 to the new element/subarray terminal on the Replace Array Subset function.

vi. Create an indicator on the output of the Replace Array Subset function. The indicator should appear as a 2D array.

vii. Run the code and verify the new valued you specified are located in the location specified by the index constants.


Hint
ManagementProgram management is the practice of overseeing programs that are aligned with corporate goals and enhance organizational performance. Program managers are responsible for directing and organizing all of the organization's programs and other strategic activities....

Know the process

Students succeed in their courses by connecting and communicating with
an expert until they receive help on their questions

1
img

Submit Question

Post project within your desired price and deadline.

2
img

Tutor Is Assigned

A quality expert with the ability to solve your project will be assigned.

3
img

Receive Help

Check order history for updates. An email as a notification will be sent.

img
Unable to find what you’re looking for?

Consult our trusted tutors.

Developed by Versioning Solutions.