LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

most efficient array handling

Hi,

I am wondering how best to manipulate arrays. I have multiple arrays which will grow over time. Once I reach a size limit I want to keep adding the most recent data to the end of the array and lose the older data at the start of the array.

It seems simple enough but I'm wondering what is best practice. I can think of two options:

array handling.PNG

 

Is one any more efficient than the other?

I seem to remeber that reversing an array is a very efficient process, but I'm unsure about rotating.

 

Thanks in advance for any insights.

 

Ian

(LV 8.5)

 

0 Kudos
Message 1 of 6
(3,472 Views)

Hi Ian,

 

I would avoid the option with the build array function as this requires the use of the memory manager. The replace array subsest is usually the best option. You mentioned the array growing, would it be possible to pre-initialise it?

 

Also it seems like you are implementing a lossy FIFO here, have you thougt about a RT FIFO (always fixed length and lossy) or a fixed length queue? Both of these options will implement the same behaviour.

 

 

Regards,

Steve.

0 Kudos
Message 2 of 6
(3,456 Views)

The "most effiecient array handling" is done in-place.

 

See this tag and its related links.

 

Post follow-up question if those don't answer your questions.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 3 of 6
(3,445 Views)

Thank you Steve and Ben,

A fixed size array makes a lot of sense now I think about it.

 

Yes, I'm trying for a FIFO but I want to fill up my array first. My end goal is to have multiple arrays plotted onto a single graph to represent the data that I am collecting from my hardware. The more data plotted on the graph the better. There will eventually be a point at which a practical limit is imposed on the size of the arrays, which is when I want to start deleting the older data.

 

Using sets of fixed length arrays would work for me. I would just have to manipulate my graph to show only the data that I want to be seeing. I think I need to run some tests comparing fixed arrays and graph property nodes against resizing arrays and straightforward graphing.

 

All the best,

Ian

 

0 Kudos
Message 4 of 6
(3,422 Views)

_Ian_ wrote:

...

 I would just have to manipulate my graph to show only the data that I want to be seeing. ...

All the best,

Ian

 


Hint:

 

The value "NaN" when presented to a graph or chart will NOT plot a point.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 5 of 6
(3,413 Views)

That should save me a bit of work.

I was about to ask how to initialise an array of NaN - but a quick search revealed its as easy as typing NaN into a numeric constant!

 

Thanks for your help - I'm good to go.

 

Ian

0 Kudos
Message 6 of 6
(3,403 Views)