LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Which is the best way to create an array of waveforms?

Hi all.

Usually, the best way to create an array is to use Initalize Array and replace elements using a while loop and a shift register, as reported here:

 

method 1.png

But... if I want to create an array of waveforms? I think that it should not the better method (from the point of view of performance).

A waveform contains several elements, in particular it contains an array of double (Y array).

So, what happen if I apply the code above with waveform (see the following figure)?

 

withWaveform.png

 

The Initialize Array function allocates a certain amount of memory for my array. The waveform used to initalize the array contains a empty array of data (Y array is empty). When the i-element is replaced in the array, the Y array is not empty and LabVIEW should allocate new memory for it. Am I right?

If my argument is correct, in this case does the auto-indexing with a for loop should be preferred rather than the previous method?

 

Thanks

0 Kudos
Message 1 of 3
(5,932 Views)

Have you tried to keep it simple,

 

ex wav array.png

 

Am not an expert on memory allocations but the posted example may be worth of consideration for simplicity's sake.

 

 

--------------------------------------------------------------------------------------------------------------------------------------------------------------------

Wisdom is the principal thing; therefore get wisdom: and with all thy getting get understanding. Proverbs 4:7
0 Kudos
Message 2 of 3
(5,925 Views)

I think in this case OP is talking about replacing some elements in the array, so pre-allocating that to the maximum array size then doing a replace is the most efficient.  The example is probably simplified.

 

That being said OP can try something like this, which will preallocate 100 waveforms with 1000 points in each.

 

Example_VI_BD.png

0 Kudos
Message 3 of 3
(5,907 Views)