Experiment No 2
To create 1D and 2D array using for loop
Aim: To create 1D and 2D array using for loop in LabVIEW.
Practical Learning Objectives:
The objective of this practical is to
i To create For loop.
ii To create 1D and 2D array using for loop for given data.
Apparatus:
Sr. No. Instrument / Component
1 PC/Laptop
2 LabVIEW
Theory: An array, which consists of elements and dimensions, is either a control or an indicator –
it cannot contain a mixture of controls and indicators. Elements are the data or values contained in
the array. A dimension is the length, height, or depth of an array. Arrays are very helpful when you
are working with a collection of similar data and when you want to store a history of repetitive
computations.
Array elements are ordered. Each element in an array has a corresponding index value, and you can
use the array index to access a specific element in that array. In NI LabVIEW software, the array
index is zero-based. This means that if a one-dimensional (1D) array contains n elements, the index
range is from 0 to n – 1, where index 0 points to the first element in the array and index n – 1 points
to the last element in the array.
Algorithm: To create an 1D array in LabVIEW
Step 1: Start the Lab view and select the blank VI.
Step 2: Create front and block diagram panel.
Step 3: Right-click on the front panel to display the Controls palette.
Step 4: On the Controls palette, navigate to Modern» Array, Matrix, & Cluster and drag the Array
shell onto the front panel.
Step 5: On the Controls palette, navigate to Modern» Numeric and drag and drop a numeric
indicator inside the Array shell.
Step 6: Place your mouse over the array and drag the right side of the array to expand it and display
multiple elements.
Step 7: Create a for loop on the block diagram and complete the connections as explained in Lab.
Block Diagram Panel:
Algorithm: To create an 2D array in LabVIEW
Step 1: Start the Labview and select the blank VI.
Step 2: Create front and block diagram panel.
Step 3: To create a 2D array, you must first create a 1D array and then add a dimension to it. Return
to the 1D array you created earlier..
Step 4: On the front panel, right-click the index display and select Add Dimension from the
shortcut menu.
Step 5: Place your mouse over the array and drag the corner of the array to expand it and display
multiple rows and columns.
Step 6: Create a for loop on the block diagram and complete the connections as explained in Lab.
Block Diagram Panel:
Result and discussion:
Front Panel:
Output:
Conclusion: -
Practical Learning Outcomes:
After performing the practical, the learner is able to: Marked
√
i To create For loop.
ii To create 1D and 2D array using for loop for given data.
i.
Outcome PLO 1 PLO 2 Performance Attendance Total Score E&TC DEPARTMENT- TCET
Date of
Weight 30 30 20 20 100 Performance: _________
Date of
Correction:___________
Roll No:_________
Score Marks: ______/100
Signature of Faculty: