LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Create 2D Array In While Loop

Solved!
Go to solution

How can I create a 2D array that is updated and displayed on the front panel after each iteration. It is 2D because I have a voltage that corresponds to a load.  I want to see the current voltage corresponding to the current load, as well as all previous voltages and loads while the while loop is still iterating

 

thanks

0 Kudos
Message 1 of 15
(19,634 Views)

Build it in a shift register.

 

If you only have two values per point, it might be easier to use a 1D complex array where RE=voltage and IM=load, for example.

0 Kudos
Message 2 of 15
(19,628 Views)

What have you tried so far? Upload your code, or if it's complicated, then a simple VI showing what you want to do, even if it doesn't work yet.

Are you trying to display this data on a graph, in a table, or in an array indicator?

Do you know the maximum amount of data that you will accumulate?

At a minimum you need a shift register containing the array. You can simply add new points to the array in the shift register, but you can make more efficient if you know in advance how much data you'll need to store.

0 Kudos
Message 3 of 15
(19,627 Views)

So I made this to give a basic idea of what I want. I want the load along with corresponding voltage to be displayed in a table, and updated after each loop, while also displaying previous values

0 Kudos
Message 4 of 15
(19,619 Views)

also I will probably only be getting 5 or 6 of each of these values, but there is about a 10min delay between each loop iteration

0 Kudos
Message 5 of 15
(19,618 Views)
Solution
Accepted by lvuser333
Message 6 of 15
(19,613 Views)

Let's start with the simple approach: build array. You need to initialize the shift register (wire a value to it from outside the loop) with an empty 2D array. Then you just need to add rows onto it using build array twice - once to build the load and voltage into a 1D array, then a second time to add that row to the 2D array.

 

There's no need for the local variables.

 

A more efficient approach would be to preallocate the entire 2D array, but since you only have a few data points with a long lag between them, efficiency isn't important so I'd try the build array approach first.

0 Kudos
Message 7 of 15
(19,609 Views)

You sir, are the man

0 Kudos
Message 8 of 15
(19,602 Views)

How did you create the empty 2D array to make it look like it does?

0 Kudos
Message 9 of 15
(19,599 Views)

How else should it look like? 😮

 

After the right shift register is hooked up, simply right-click the left shift register and select "create constant".

 

Other possibilities:

  • drop an empty array container constant from the array palette and drop a DBL numeric constant into it.
  • ...
0 Kudos
Message 10 of 15
(19,597 Views)