キャンセル
次の結果を表示 
次の代わりに検索 
もしかして: 

Create 2D Array In While Loop

解決済み
解決策を見る

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 件の賞賛
メッセージ1/15
21,176件の閲覧回数

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 件の賞賛
メッセージ2/15
21,170件の閲覧回数

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 件の賞賛
メッセージ3/15
21,169件の閲覧回数

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 件の賞賛
メッセージ4/15
21,161件の閲覧回数

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 件の賞賛
メッセージ5/15
21,160件の閲覧回数
解決策
トピック作成者lvuser333が受理
メッセージ6/15
21,155件の閲覧回数

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 件の賞賛
メッセージ7/15
21,151件の閲覧回数

You sir, are the man

0 件の賞賛
メッセージ8/15
21,144件の閲覧回数

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

0 件の賞賛
メッセージ9/15
21,141件の閲覧回数

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 件の賞賛
メッセージ10/15
21,139件の閲覧回数