NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

How to append 1D array to 2D array (locals)?

Hello,

 

I have 1D array of data set and need to store that information to Locals (2D array). Each loop I get 1D array data set and append to the 2D array Locals and at the end of the loop, read the Locals and analyze the data. How can I append 1D array to 2D array Locals variable (directly in TestStand)? Thank you in advance.

 

 

0 Kudos
Message 1 of 5
(6,497 Views)

Hello, to insert into a 2d array you have to insert one element at a time. You will need another sub loop that runs through each element of the 1d array that you want to insert into your 2d array.

 

Hope that helps

National Instruments
0 Kudos
Message 2 of 5
(6,429 Views)

Or you can try a trick with only one loop 😃 See the attachment.. The recipe is simple:

1. Create Custom data type - Array of ... (type "array" in the example)

2. Create Locals variable of your type "array" - Locals.array1D

3. Create 1D array of elements of type "array" - Locals.array2D

4. Perform a loop for Locals.array2D, on each iteration its current ellement will be defined

5. Access element of a 2D array via Locals.array2D[x][y].. Locals.array2D is a 1D array formaly, but its elements are 1D arrays too. That is why you get a 2D array

 

Hope that helps,

Max

Message 3 of 5
(6,405 Views)

Hi

1- Concatenate two arrays to a One Dimensional Array with the += Operator

         (Locals.Combined2D += Parameters.Independant) += Parameters.Dependant

 

2- Re-Shape the result to a Two Dimensional Array using the length of one of the original Arrays as Parameter

         Locals.Combined2D.Type.ArrayDimensions.SetBounds ( { 0 , 0 } , {Parameters.Independant.GetNumElements() - 1 , 1} )

Message 4 of 5
(3,084 Views)

this sequence contains an error:  

(Locals.Combined2D += Parameters.Independant) += Parameters.Dependant

Expressions must evaluate to a value of the expected type

0 Kudos
Message 5 of 5
(1,822 Views)